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

时间:2020-12-20 16:24:00

题目链接: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{
    ];
    int p;
}c[N];
int cntp[M];

int main()
{
    //freopen("d:\\in.txt", "r", stdin);
    int s, n;
    while(cin>>s>>n){
        memset(cntp, , sizeof(cntp));
        ; i<n; i++){
            cin>>c[i].name>>c[i].p;
            cntp[c[i].p]++;
        }
        int minp = M, k;
        ; i<= ; i++){
            if(cntp[i] && cntp[i]<minp){
                minp = cntp[i];
                k = i;
            }
        }
        int i;
        ; 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);
    }
    ;
}