What Is Your Grade?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10831 Accepted Submission(s): 3370
Total Submission(s): 10831 Accepted Submission(s): 3370
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
这道题目用了几个数组去存做了4个,3个,2个,1个的人;反正就是照着题目意思一步步的模拟,谨慎就好
#include<iostream> #include<algorithm> #include<string> #include<map> #include<stdio.h> using namespace std; struct stu { int p,time,mark; }Num[102]; void t_rank(int *a,int l) { int i,j,t; for(i=0;i<l;i++) { for(j=i+1;j<l;j++) { if(Num[a[j]].time <Num[a[i]].time ) { t=a[i]; a[i]=a[j]; a[j]=t; } } } for(i=0;i<l;i++) Num[a[i]].mark=i+1; } int main() { int a4[102],len4,a3[102],len3,a2[102],len2,a1[102],len1; int n,p,h,m,s,i; while(cin>>n&&n>=0) { len4=len3=len2=len1=0; for(i=0;i<n;i++){ scanf_s("%d %d:%d:%d",&p,&h,&m,&s); Num[i].p=p; Num[i].time=h*3600+m*60+s; switch(p) { case 4: a4[len4++]=i;break; case 3: a3[len3++]=i;break; case 2: a2[len2++]=i;break; case 1: a1[len1++]=i;break; default:break; } } t_rank(a4,len4); t_rank(a3,len3); t_rank(a2,len2); t_rank(a1,len1); for(i=0;i<n;i++) { if(Num[i].p==5) cout<<100<<endl; else if(Num[i].p==0) cout<<50<<endl; else if(Num[i].p==4) { if(Num[i].mark<=len4/2) cout<<95<<endl; else cout<<90<<endl; } else if(Num[i].p==3) { if(Num[i].mark<=len3/2) cout<<85<<endl; else cout<<80<<endl; } else if(Num[i].p==2) { if(Num[i].mark<=len2/2) cout<<75<<endl; else cout<<70<<endl; } else if(Num[i].p==1) { if(Num[i].mark<=len1/2) cout<<65<<endl; else cout<<60<<endl; } } cout<<endl; } return 0; }