Description
“Point, point, life of student!”
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!
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!
Input
Input contains multiple test cases. Each test case contains an integer N (1<=N<=100, the number of students) in a line first, and then N lines follow. Each line contains P (0<=P<=5 number of problems that have been solved) and T(consumed time). You can assume that all data are different when 0<p.
A test case starting with a negative integer terminates the input and this test case should not to be processed.
A test case starting with a negative integer terminates the input and this test case should not to be processed.
Output
Output the scores of N students in N lines for each case, and there is a blank line after each case.
Sample Input
4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
5 06:30:17
-1
Sample Output
100
90
90
95
100
思路:这题大概意思是解决5题可能拿100分,解决4题可以拿90或者95分(3 2 1题以此类推)(
你的排名排在班上解决了同样题数的同学中的前半部分可以拿95,例如解决4题的有4个,钱2个拿95,后两个拿90,5题,前两个拿95,后3个拿90)
),但一题也没做出来的50分(不及格哦T.T)。。。。用结构体存题数,时间,编号,成绩,然后排序(如果题数大的拍前面,相同的时间少排前面)。然后我再开一个结构体存该题目解决人数和每人解决该题数所用时间,通过如果时间小于等中间那个人的时间,那他的分数+5。然后通过编号再排序输出。。。。。
PS:陷阱(如果该题目解决的只有1人,他不会+5的)
我的测试样例:
4
5 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
4 06:30:17
1
0 00:00:00
-1
100
90
90
95
90
50
代码:
View Code
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; struct student { int problem; int score; int time; int bianhao; }; struct a { int times[110]; int count; }; bool cmp(student stud1,student stud2) { if(stud1.problem!=stud2.problem) { return stud1.problem>stud2.problem; } else { return stud1.time<stud2.time; } } bool cmp1(student stud1,student stud2) { return stud1.bianhao<stud2.bianhao; } int main() { #ifdef CDZSC_OFFLINE freopen("in.txt","r",stdin); #endif int n,i,h,m,s; student stud[110]; a studs[6]; while(scanf("%d",&n)&&n!=-1) { for(i=0; i<6; i++) { studs[i].count=0; } for(i=0; i<n; i++) { scanf("%d",&stud[i].problem); scanf("%d:%d:%d",&h,&m,&s); stud[i].time=h*3600+m*60+s; stud[i].score=50+10*stud[i].problem; stud[i].bianhao=i; } sort(stud,stud+n,cmp); for(i=0; i<n; i++) { studs[stud[i].problem].times[studs[stud[i].problem].count]=stud[i].time; studs[stud[i].problem].count++; } for(i=0; i<n; i++) { if(stud[i].problem!=5&&stud[i].problem!=0&&stud[i].time<=studs[stud[i].problem].times[studs[stud[i].problem].count/2-1]) { stud[i].score+=5; } } sort(stud,stud+n,cmp1); for(i=0; i<n; i++) { printf("%d ",stud[i].score); } printf(" "); } return 0; }