What Is Your Grade?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8255 Accepted Submission(s): 2529
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
解析:這個題目中有點沒有說清楚,當題目的數量只有一個人的時候給予的分數是少的。
貼一下自己的代碼,代碼寫的很長,但是很清楚哈!
#include<iostream>
#include <string>
#include <algorithm>
using std::endl;
using std::cin;
using std::cout;
using std::string;
using std::sort;
const int MAXN = 100 + 10;
struct grade{
//題目的數量
int numSolved;
//時間
string time;
//標號
int flag;
//存放最終的成績
int score;
}stu[MAXN];
//記錄解決相同的題目數的人數
int count[6];
//首先按照題目數量降序,題目數相同時按照時間遞增排序
bool cmp_1(grade a , grade b)
{
if(a.numSolved > b.numSolved)
return true;
if(a.numSolved == b.numSolved)
return (a.time < b.time);
return false;
}
//按照標號進行排序
bool cmp_2(grade a , grade b)
{
return a.flag < b.flag;
}
int main()
{
#ifdef LOCAL
freopen("input.txt" , "r" , stdin);
#endif
int N;
while(cin >> N)
{
//重置
memset(count , 0 ,sizeof count);
if(N<0)
break;
//輸入數據
for(int i=0; i<N;++i)
{
cin >> stu[i].numSolved >> stu[i].time;
stu[i].flag = i;
count[stu[i].numSolved]++;
}
//排序
sort(stu , stu+N , cmp_1);
int cnt_2 = 0 , cnt_3 = 0 , cnt_4 = 0 ,cnt_1 = 0;
//開始計算成績
for(int i=0; i<N;++i)
{
if(stu[i].numSolved == 0)
{
stu[i].score = 50;
}
if(stu[i].numSolved == 5)
{
stu[i].score = 100;
}
if(stu[i].numSolved == 4)
{
cnt_4++;
if(cnt_4 <= count[4]/2)
{
stu[i].score = 95;
}else{
stu[i].score = 90;
}
}
if(stu[i].numSolved == 3)
{
cnt_3++;
if(cnt_3 <= count[3]/2)
{
stu[i].score = 85;
}else{
stu[i].score = 80;
}
}
if(stu[i].numSolved == 2)
{
cnt_2++;
if(cnt_2 <= count[2]/2)
{
stu[i].score = 75;
}else{
stu[i].score = 70;
}
}
if(stu[i].numSolved == 1)
{
cnt_1++;
if(cnt_1 <= count[1]/2)
{
stu[i].score = 65;
}else{
stu[i].score = 60;
}
}
}
//排序進行輸出成績
sort(stu , stu+N , cmp_2);
for(int i=0;i<N;++i)
{
cout << stu[i].score << endl;
}
cout << endl;
}
return 0;
}