“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!
InputInput 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.
OutputOutput 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
刚看到这个题目的时候有点懵,但是尝试着写了一下。。。。思路简单的很
#include<iostream> #include<algorithm> #include<string> #include<cstdio> #include<math.h> using namespace std; struct stu { int a; string b; int c;//记录当前的分数 }; //先用sort对副本数组num2排序,a优先,b其次,c不用管 ,最后在转换为num1 bool cmp(stu x,stu y) { if(x.a!=y.a) return x.a>y.a; return x.b<y.b;//时间取较小的 } int main() { int n; while(cin>>n) { int s[6]={0};//,一定要定义在循环内部,,,错了好几次 struct stu num1[111],num2[111]; if(n<0) break; for(int i=0;i<n;i++) { cin>>num1[i].a>>num1[i].b; num2[i].a=num1[i].a; num2[i].b=num1[i].b; s[num1[i].a]++;//记录每个值出现的次数 } sort(num2,num2+n,cmp); int x=0,y=0,z=0,w=0; for(int i=0;i<n;i++) { if(num2[i].a==5) { num2[i].c=100; } else if(num2[i].a==4) { x++;//记录4出现的次数 if(s[4]==1) num2[i].c=95; else { if(s[4]/2>=x)//如果4出现的次数比中值小 则赋值为95,否则 90 { num2[i].c=95; } else { num2[i].c=90; } } } else if(num2[i].a==3) { y++; if(s[3]==1) num2[i].c=85; else { if(s[3]/2>=y) { num2[i].c=85; } else { num2[i].c=80; } } } else if(num2[i].a==2) { z++; if(s[2]==1) num2[i].c=75; else { if(s[2]/2>=z) { num2[i].c=75; } else { num2[i].c=70; } } } else if(num2[i].a==1) { w++; if(s[1]==1) num2[i].c=65; else { if(s[1]/2>=w) { num2[i].c=65; } else { num2[i].c=60; } } } else if(num2[i].a==0) { num2[i].c=50; } } //转换 根据num2 对num1 中的c赋值 for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { if(num1[i].a==num2[j].a && num1[i].b==num2[j].b) { num1[i].c=num2[j].c; break; } } } for(int i=0;i<n;i++) cout<<num1[i].c<<endl; cout<<endl; } return 0; } //自己造的数据 /* 15 5 06:30:17 4 07:31:27 4 08:12:12 4 05:23:13 4 06:30:17 3 05:23:13 3 05:23:12 3 05:23:11 3 05:23:10 3 05:23:09 2 06:30:17 2 06:30:12 1 05:23:01 0 08:12:12 */