题目:http://acm.hdu.edu.cn/showproblem.php?pid=1177
代码:
//4 =< N <= 130 G, S, C (1<=G<=S<=C<N --G, S, C M (0<M<=N).
//1<=P<=8 --number time T(for example,"02:45:17",
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct student
{
int p,no;
string t;
};
int cmp(student a,student b)
{
if(a.p!=b.p)return a.p>b.p;
else if(a.t!=b.t) return a.t<b.t;
return a.no<b.no;
}
int main()
{
int n,g,s,c,m,i;
student stu[135];
while(cin>>n>>g>>s>>c>>m)
{
if(n==0&&g==0&&s==0&&c==0&&m==0)break;
for(i=0;i<n;i++)
{ cin>>stu[i].p>>stu[i].t;stu[i].no=i+1; }
sort(stu,stu+n,cmp);
//for(i=0;i<n;i++)
//cout<<stu[i].p<<' '<<stu[i].t<<endl;
for(i=0;i<n;i++)
if(stu[i].no==m)
{
if(i+1<=g){printf("Accepted today? I've got a golden medal :)/n");break;}
if(i+1<=g+s){printf("Accepted today? I've got a silver medal :)/n");break;}
if(i+1<=g+s+c){printf("Accepted today? I've got a copper medal :)/n");break;}
printf("Accepted today? I've got an honor mentioned :)/n");break;
}
}
return 0;
}