300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > [河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)

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

时间:2020-05-01 17:48:34

相关推荐

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

题目链接:/JudgeOnline/problem.php?pid=251

规则:

1、若某竞标价唯一,则胜出

2、若不存在唯一竞标价,则投标次数最少竞标价中标,存在多个时,选择价钱最低且最先投此价钱的为中标

#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define N 102#define M 1002struct Node{char name[6];int p;}c[N];int cntp[M];int main(){//freopen("d:\\in.txt", "r", stdin);int s, n;while(cin>>s>>n){memset(cntp, 0, sizeof(cntp));for(int i=0; i<n; i++){cin>>c[i].name>>c[i].p;cntp[c[i].p]++; }int minp = M, k;for(int i=1; i<= 1000; i++){if(cntp[i] && cntp[i]<minp){minp = cntp[i];k = i;}} int i;for(i=0; i<N; i++){if(c[i].p == k)break; } printf("The winner is %s\nThe price is %d\n", c[i].name, c[i].p);} return 0;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。