您的位置:首页 > 其它

【杭电-oj】-1084-What Is Your Grade?(结构体)

2016-07-19 20:23 465 查看


What Is Your Grade?

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 10687 Accepted Submission(s): 3311



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!

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.

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


1,时间换成秒比较好算

2,原样排序输出成绩,开始要对其进行编号

3,做题数目相同前一半人加分,可以用一个数组分别记下做出几道题得人数,最后除以二,得到一半(注意个数为1),输出一个,个数减一,个数为零,不加分。

#include<cstdio>
#include<algorithm>
using namespace std;
struct people
{
int num;
int a,b,c;
int ant;
int cj,sx;
}a[110];
bool cmp1(people a,people b)
{
if(a.num==b.num)				//解决题数相同,比较时间
return a.ant<b.ant;
else
return a.num>b.num;
}
bool cmp2(people a,people b)
{
return a.sx<b.sx;				//因为要原样排序输出成绩,所以要对开始的输入进行标号,及记下来顺序
}
int main()
{
int n,b[7]={0};
while(~scanf("%d",&n)&&n>0)
{
for(int i=1;i<=n;i++)
{
scanf("%d %d:%d:%d",&a[i].num,&a[i].a,&a[i].b,&a[i].c);
a[i].ant=a[i].a*3600+a[i].b*60+a[i].c;			//为了方便比较时间,把时间全部换成秒
a[i].sx=i;
if(a[i].num==1)
b[1]++;							//用b[i]记下解决i道题的人数
else if(a[i].num==2)
b[2]++;
else if(a[i].num==3)
b[3]++;
else if(a[i].num==4)
b[4]++;
else if(a[i].num==5)
b[5]++;
}
for(int i=1;i<=5;i++)
if(b[i]>1)					//大于1时 不除以2(除以2使变为一半),不然会为0
b[i]/=2;
sort(a+1,a+n+1,cmp1);			//解决题目,及时间排序
for(int i=1;i<=n;i++)
{
if(a[i].num==5)
a[i].cj=100;
else if(a[i].num==0)
a[i].cj=50;
else if(a[i].num==4)
{
if(b[4]>0)					//b[i]>0,说明 前一半还有人,加5。不然不加
{
a[i].cj=95;
b[4]--;
}
else
a[i].cj=90;
}
else if(a[i].num==3)
{
if(b[3]>0)
{
a[i].cj=85;
b[3]--;
}
else
a[i].cj=80;
}
else if(a[i].num==2)
{
if(b[2]>0)
{
a[i].cj=75;
b[2]--;
}
else
a[i].cj=70;
}
else if(a[i].num==1)
{
if(b[1]>0)
{
a[i].cj=65;
b[1]--;
}
else
a[i].cj=60;
}
}
sort(a+1,a+1+n,cmp2);			//恢复顺序
for(int i=1;i<=n;i++)
printf("%d\n",a[i].cj);
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: