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. 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. 

输入
There are multi test cases.EOF will terminate the input.
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、若某竞标价唯一,则胜出
2、若不存在唯一竞标价,则投标次数最少竞标价中标,存在多个时,选择价钱最低且最先投此价钱的为中标

源代码:
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 102
#define M 1002

struct Node
{
	char name[6];
	int p;
}c[N];
int cntp[M];
int main()
{
	int i,s,n;
	while(cin>>s>>n)
	{
		memset(cntp,0,sizeof(cntp));
		for(i=0;i<n;i++)
		{
			cin>>c[i].name>>c[i].p;
			cntp[c[i].p]++;  	
		}
		int minp=M,k;
		for(i=1;i<=1000;i++)
		{
			if(cntp[i] && cntp[i]<minp)
			{
				minp=cntp[i];
				k=i;
			}
		}
		for(i=0;i<N;i++)
		{
			if(c[i].p==k)
			  break;
		}
		cout<<"The winner is "<<c[i].name<<endl<<"The price is "<<c[i].p<<endl;
	}
	return 0;
}
“Magic Amazing” 是一种结合了英语单词 “magic”(魔法)和 “amazing”(令人惊奇的)的说法,通常用来形容某事物非常神奇、令人惊叹不已。这种表达在日常生活中用于赞美某个现象、表演或技术所带来的震撼效果。以下是对这两个词的具体介绍及其组合使用的场景说明: ### Magic(魔法) - **含义**:指超自然的力量或技艺,能够产生不可思议的效果;也可以泛指让人感到神秘莫测的事物。 - **应用场景**: - 魔术师在舞台上展示的各种幻术就是典型的魔法表现形式。 - 科技产品带来的创新体验有时也会被用户比喻为现代版的魔法。 ### Amazing(令人惊奇的) - **含义**:表示某种东西极其出色、非凡,超出预期的好或有趣,使人印象深刻并充满惊讶之感。 - **应用场景**: - 当看到壮丽的日落景色时可以说:“这景象真是Amazing!” - 对于一项新的发明创造,人们会感叹其功能是多么Amazing。 ### Magic Amazing 组合使用 当我们将两个词语结合起来说 "Magic Amazing" 时,意味着某件事情不仅具有魔力般的特质,而且还具备强烈的视觉冲击力或者情感触动能力,足以让人为之一振。例如,在观看了一场精彩的魔术秀之后,观众可能会这样评价:“这场演出真的是Magic Amazing!” 此外,“Magic Amazing” 还可能出现在广告宣传语中,用来吸引消费者的注意力,突出产品的独特魅力。比如一款新型智能手机发布时声称拥有许多前所未见的功能特性,则可以用这个短语来形容它给用户体验上带来的惊喜变化。 总之,“Magic Amazing” 强调的是那种超越常规认知边界、给人带来强烈正面情绪反应的感觉。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值