What Is Your Grade?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6917 Accepted Submission(s): 2122
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
题目大意:每一类别有一个基础分,然后如果你在这一类别的前一半,可以加5分。50和100不用判断。
解题思路:直接模拟,不过这个题目开始竟然WA了,是因为0道题目的时候也有时间输入。
题目地址:What Is Your Grade?
AC代码:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
struct mq
{
int lx; //类型
int score; //记录得分
int h; //时
int m; //分
int s; //秒
int rank1; //在同类的排名
};
mq node[102];
int total[6]; //记录1~4同类的总数
int main()
{
int n,i,j,t;
char s[102];
while(scanf("%d",&n))
{
if(n<0) break;
memset(total,0,sizeof(total));
for(i=1;i<=n;i++)
{
scanf("%d",&t);
node[i].lx=t; //类别
node[i].score=50+t*10; //这是基础分
total[t]++;
scanf("%s",s);
node[i].h=(s[0]-'0')*10+(s[1]-'0');
node[i].m=(s[3]-'0')*10+(s[4]-'0');
node[i].s=(s[6]-'0')*10+(s[7]-'0');
node[i].rank1=1;
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{
if(j==i) continue;
if(node[j].lx==node[i].lx) //得出每个人的排名
{
if(node[j].h<node[i].h)
node[i].rank1++;
else if(node[j].h==node[i].h&&node[j].m<node[i].m)
node[i].rank1++;
else if(node[j].h==node[i].h&&node[j].m==node[i].m&&node[j].s<node[j].s)
node[i].rank1++;
}
}
for(i=1;i<=n;i++)
{
int tmp=node[i].lx;
if(tmp>0&&tmp<5)
{
if(total[tmp]/node[i].rank1>=2) //排在前一半+5分
node[i].score+=5;
}
}
for(i=1;i<=n;i++)
printf("%d\n",node[i].score);
puts("");
}
return 0;
}