What Is Your Grade?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9540 Accepted Submission(s): 2934
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Node{
int grade;//最后分数
int No; //同组中的排名
int t; //作出题目
int time;
int bsNo; //原始顺序号
}a[120];
int cmp1(constvoid *a,constvoid *b){ //如果作出题目一样,以time为准小-》大
struct Node *c=(structNode *)a;
struct Node *d=(structNode *)b;
if(c->t==d->t)return c->time-d->time;
return d->t - c->t;
}
int cmp2(const void *a,const void *b) //返回初始顺序
{
struct Node *c=(structNode *)a;
struct Node *d=(structNode *)b;
return c->bsNo-d->bsNo;
}
int main()
{
int rs[6];
int N;
while (scanf("%d",&N)!=EOF&&N>=0) {
memset(rs, 0,sizeof(rs));
for (int i=0; i<N; i++) {
int m,s,h;
scanf("%d %d:%d:%d",&a[i].t,&h,&m,&s);
a[i].time = h*3600+m*60+s;
rs[a[i].t]++;
a[i].bsNo=i;
}
qsort(a, N,sizeof(a[0]),cmp1);
a[0].No=1;
for (int i=1; i<N; i++) {
a[i].No=1;
if(a[i].t==a[i-1].t)
a[i].No+=a[i-1].No;
}
for (int i=0; i<N; i++) {
a[i].grade=a[i].t*10+50;
if((a[i].t>=1&&a[i].t<5)&&a[i].No<=rs[a[i].t]/2)
a[i].grade+=5;
}
qsort(a, N,sizeof(a[0]),cmp2);
for (int i=0; i<N; i++) {
printf("%d\n",a[i].grade);
}
printf("\n");
}
return 0;
}