Problem 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
Author
lcy
题意:输入一个整数,代表人数,后面每一行是考生信息,分别是该考生完成的题目数目以及所用的时间。在答完n到题目的考试中,只有排名前二分之一才能得到较多的分数(95,85,75,65)。
用两个sort函数,第一个用来按答出题目多少来排序,如果所答的题目数量一样,则按他们所消耗的时间排序。第二个sort用来恢复输入时考生的顺序。最后逐次输出成绩。
代码如下:
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct student{
int m;
char time[110];
int point;
int l;
}arr[110];
bool cmp1(student a,student b){
if(a.m==b.m){
return strcmp(a.time,b.time)<0;
}
else
return a.m>b.m;
}
bool cmp2(student a,student b){
return a.l<b.l;
}
int main()
{
int n,i,t;
while(scanf("%d",&n)!=EOF){
int x=0,y=0,z=0,l=0;
if(n<0)break;
for(i=0;i<n;i++){
scanf("%d %s",&arr[i].m,arr[i].time);
arr[i].l=i;
if(arr[i].m==4)
x++;
if(arr[i].m==3)
y++;
if(arr[i].m==2)
z++;
if(arr[i].m==1)
l++;
}
sort(arr,arr+n,cmp1);
int flag=1,ant=1,ans=1,anx=1;
for(i=0;i<n;i++){
if(arr[i].m==5)
arr[i].point=100;
if(arr[i].m==4&&flag<=x/2)
{
arr[i].point=95;
flag++;
}
else if(arr[i].m==4&&flag>x/2)
arr[i].point=90;
if(arr[i].m==3&&ant<=y/2)
{
ant++;
arr[i].point=85;
}
else if(arr[i].m==3&&ant>y/2)
arr[i].point=80;
if(arr[i].m==2&&ans<=z/2)
{
ans++;
arr[i].point=75;
}
else if(arr[i].m==2&&ans>z/2)
arr[i].point=70;
if(arr[i].m==1&&anx<=l/2)
{
anx++;
arr[i].point=65;
}
else if(arr[i].m==1&&anx>l/2)
arr[i].point=60;
if(arr[i].m==0)
{
arr[i].point=50;
}
}
sort(arr,arr+n,cmp2);
for(i=0;i<n;i++){
printf("%d\n",arr[i].point);
}
printf("\n");
}
}