标签:
题目链接: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 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; }
[河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)
标签:
原文地址:http://www.cnblogs.com/vegg117/p/4387466.html