AMAZING AUCTION (第三届省赛)

AMAZING AUCTION

(这道麽。。。。英文题,,硬伤, 也是队友写的;题意是 从数据中找到与众不同的数据, 且该价钱是最低的(也就是竞标)  代码应该不难);

题目描述

Recently the auction house has introduced a new type of auction, the lowest price auction. In this new system, people compete for the lowest bid price, as opposed to what they did in the past. What an amazing thing! Now you could buy cool stuff with one penny. Your task is to write the software to automate this auction system.

First the auctioneer puts an upper limit on bid price for each item. Only positive price less than or equal to this price limit is a valid bid. For example, if the price limit is 100, then 1 to 100, inclusive, are all valid bid prices. Bidder can not put more than one bid for the same price on a same item. However they can put many bids on a same item, as long as the prices are different.

After all bids are set, the auctioneer chooses the winner according to the following rules:

(1). If any valid price comes from only one bidder, the price is a "unique bid". If there are unique bids, then the unique bid with the lowest price wins. This price is the winning price and the only bidder is the winning bidder.

(2). If there are no unique bids, then the price with fewest bids is the winning bid. If there are more than one price which has the same lowest bid count, choose the lowest one. This price is the winning price. The bidder who puts this bid first is the winning bidder.

Given the price limit and all the bids that happen in order, you will determine the winning bidder and the winning price.

输入

The first line contains two integers: U (1 <= U <= 1000), the price upper limit and M (1 <= M <= 100), the total number of bids. M lines follow, each of which presents a single bid. The bid contains the bidder‘s name (consecutive non-whitespace characters<=5) and the price P (1 <= P <= U), separated with a single space. All bids in the input are guaranteed to be valid ones.

输出

Print the sentence "The winner is W" on the first line, and "The price is P" on the second.

样例输入

30 7
Mary 10
Mary 20
Mary 30
Bob 10
Bob 30
Carl 30
Alice 23

样例输出

The winner is Mary
The price is 20
 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<string.h>
 4 #include<ctype.h>
 5 #define N 1010
 6 #define max(a, b)(a > b ? a : b)
 7
 8 typedef struct node
 9 {
10     char s[10];
11     int p;
12 } node;
13
14 int cmp(const void *a, const void *b)
15 {
16     node *s1 = (node *)a, *s2 = (node *)b;
17     return s1->p - s2->p;
18 }
19 int main()
20 {
21     node node[N];
22     int m, n, i, x, a[N];
23     char str[N];
24     while(scanf("%d%d", &m, &n) != EOF)
25     {
26         memset(a, 0, sizeof(a));
27         for(i = 0 ; i < n ; i++)
28         {
29             scanf("%s%d", node[i].s, &node[i].p);
30             a[node[i].p]++;
31         }
32         qsort(node, n, sizeof(node[0]), cmp);
33         for(i = 0 ; i < n ; i++)
34         {
35             if(node[i].p <= m && a[node[i].p] == 1)
36             {
37                 strcpy(str, node[i].s);
38                 x = node[i].p;
39                 break;
40             }
41         }
42         printf("The winner is %s\nThe price is %d\n", str, x);
43     }
44     return 0;
45 }
时间: 2024-07-29 11:23:52

AMAZING AUCTION (第三届省赛)的相关文章

河南省第三届acm省赛 AMAZING AUCTION

AMAZING AUCTION 时间限制:3000 ms  |  内存限制:65535 KB 难度:4 描述 Recently the auction house has introduced a new type of auction, the lowest price auction. In this new system, people compete for the lowest bid price, as opposed to what they did in the past. Wh

[河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=251 规则: 1.若某竞标价唯一,则胜出 2.若不存在唯一竞标价,则投标次数最少竞标价中标,存在多个时,选择价钱最低且最先投此价钱的为中标 #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define N 102 #define M 1002 struct N

山科第三届校赛总结

这次山科的校赛算是省赛前的一次正式的检验吧,暴露了我们队伍之前训练很多没发现的问题. 比赛的过程真的算是有惊无险,差点就GG... 我们入场晚了一会,我刚读完C题,就发现已经有人过了F题了,我去看F题,是个统计闰年的水题,很快就敲过了.回去想接着看C,感觉也很水,这时cerberux说这个用个map就A了,我让他来敲,可是他好像用的不是很熟练,这道题敲的很慢,交上去还wa了...我回过头仔细看这题,觉得扫一遍统计一次最多连续出现的次数就可以了,这才把这个水题过了.然后我去敲G,G题我出现了很严重

第三届山西省赛1004 一道大水题(scanf)

一道大水题 时间限制: C/C++ 2000ms; Java 4000ms 内存限制: 65535KB 通过次数: 44 总提交次数: 1020 问题描述 Dr. Pan作为上兰帝国ACM的总负责人,对队员的队员的训练也是日常关心,他要求每周要有一位队员出一道题目.不知过了多少年,终于轮到Shiyiliang出题了,他费尽脑汁,终于出了一道大水题 给定一个偶数n,n的取值范围为[-1e18,1e18],要求一对整数x,y满足以下条件: 1.x*y==n 2.x与n必须同号,即如果n>0则x>0

东北农业大学第三届校赛总结

2014年11月9日,晴,天气还不错.早上8点匆匆赶到实验室和大家集合,一起去了东北农业大学. 刚到校门口就感受到了东北农业大学的大了,不过美中不足的是有点荒凉,校园是很空旷,但是除了几栋楼之外,剩下的都是荒地,或许还未建设好吧. 9点到达了农大,对着门的是农大最好的一栋楼--成栋楼,真的好霸气,唉,一比,黑大真是弱爆了,211就是不一样啊... 9点半是热身赛,一个小时,刚开始,上来一个大水题A题,求个平均数:然后是B题,也很水,只不过是太小看他了,直接暴力搞的,信心满满的交了,WA...我改

房间安排(第三届省赛)

房间安排 (用一个数组a[]存储某一天内需要住房的房间数, 因为你至少要满足需要在同一天住的人都有房间, 用maxn 存储需要的房间数  不断与a[i]比较) 题目描述 2010年上海世界博览会(Expo 2010),是第41届世界博览会.于2010年5月1日至10月31日期间,在中国上海市举行.本次世博会也是由中国举办的首届世界博览会.上海世博会以“城市,让生活更美好”(Better City, Better Life)为主题,将充分探索21世纪城市生活. 这次世博会总投资达450亿人民币,创

网络的可靠性 (第三届省赛)

网络的可靠性 (这道题就比较开心了, 看一下题目中被画红的句子, 由此我们可以得出任意一个基站至少要连有两个光纤路线才满足题意:这样想的话就非常简单的, 只需要查找一次就可以了, 找出有多少个不满足题意的基站就欧克了    PS :输出是(num+1)/2  这是因为 若n个基站不满足条件的话将n个基站两两相连只需n/2就可以满足题意(n为奇数的话就需要多加一)) 题目描述 A公司是全球领先的互联网解决方案提供商,也是 2010 年世博会的高级赞助商.它将提供先进的网络协作技术,展示其 智能+互

BUYING FEED (第三届省赛)

BUYING FEED (英文题!!!!   为那些跟我一样acmer翻译一下吧  是实话 看不懂题真的很烦人     以上都是废话, 下面解释 英文题不出意外还是队友写的, 题意是第一行输入  要买的量k   要走的总长度e   店铺的数量n :    然后就是每家店铺距离起点的距离    存货量    成本   . ps : 将一单位的物品移动一个单位的距离要花费1磅运费: 求  需要花费的最小的成本: (这道题的解题思路在于按照  将每家店铺以单位的物品运到终点所需要的成本 排序, 然后从

聪明的“KK” (第三届省赛)

聪明的“KK” (代码并不是很长   这道题是队友写的, 思路是:读入每个数以后 在这个数的位置上 存入从起点到这个点 的最大的值 , 最后右下角的的那个值就是结果) 题目描述 非洲某国展馆的设计灵感源于富有传奇色彩的沙漠中陡然起伏的沙丘,体现出本国不断变换和绚丽多彩的自然风光与城市风貌.展馆由五部分组成,馆内影院播放名为<一眨眼的瞬间>的宽银幕短片,反映了建国以来人民生活水平和城市居住环境的惊人巨变. 可移动“沙丘”变戏法 的灵感源于其独特而雄伟的自然景观——富于传奇色彩的险峻沙丘.宏伟的结