This is a ballad(歌谣)well known in colleges, and you must care about your score in this exam too. How many points can you get? Now, I told you the rules which are used in this course.
There are 5 problems in this final exam. And I will give you 100 points if you can solve all 5 problems; of course, it is fairly difficulty for many of you. If you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former(前者) only when your rank is in the first half of all students who solve 4 problems). Analogically(以此类推), you can get 85、80、75、70、65、60. But you will not pass this exam if you solve nothing problem, and I will mark your score with 50.
Note, only 1 student will get the score 95 when 3 students have solved 4 problems.
I wish you all can pass the exam!
Come on!
A test case starting with a negative integer terminates the input and this test case should not to be processed.
4 5 06:30:17 4 07:31:27 4 08:12:12 4 05:23:13 1 5 06:30:17 -1
100 90 90 95 100
分析:
题目的意思是像95的给法首先前提必须是做了4题,此外用时还必须最少(假设有2或3人) ,若是有4或5个人则得到95的必定是2人;
代码:
#include<stdio.h>
#include<algorithm>
using namespace std;
struct student
{
int num;
int s;
int fen;
int id;
}p[100];
int arr[6];
bool cmp1(student a,student b)
{if(a.num==b.num)
return a.s<b.s;
return a.num>b.num;
}
bool cmp2(student a,student b)
{
return a.id<b.id ;
}
int main()
{int n,h,m,s,num;
while(scanf("%d",&n)==1&&n>0)
{
for(int i=1;i<6;i++)
arr[i]=0;
for(int i=0;i<n;i++)
{
scanf("%d %d:%d:%d", &num, &h, &m, &s);
p[i].s=m * 60 + h * 3600+s;
p[i].id =i;
p[i].num =num;
p[i].fen =100-(5-num)*10;
arr[num]++;
}
sort(p,p+n,cmp1);
for(int i=4,id=0;i;i--)
{if(arr[i])
while(p[id].num !=i)
id++;
if(arr[i]==1)
p[id++].fen +=5;
for(int j=0;j<arr[i]/2;j++)
p[id++].fen +=5;
}
sort(p, p+ n, cmp2);
for(int i = 0; i < n; ++i)
printf("%d\n", p[i].fen );
printf("\n");
}
return 0;
}