http://acm.hdu.edu.cn/showproblem.php?pid=1084
模拟题,使用表驱动避免大量判断。注意当只有一个人做出n道题时( n < 5 && n > 0 ),他的分数+5。
| Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
| 4255746 | 2011-07-25 22:01:25 | Accepted | 1084 | 0MS | 348K | 1954 B | G++ | GongZi |
//HDOJ 1084 Code By NetBeans 6.9.1
#include <iostream>
#include <cstdio>
#include <memory.h>
#include <algorithm>
using namespace std;
struct STUDTYPE
{
int order;
int solved_num;
long long time;
int score;
};
bool cmp_by_solve_num(STUDTYPE x, STUDTYPE y);
bool cmp_by_order(STUDTYPE x, STUDTYPE y);
int default_score[6] = {50, 60, 70, 80, 90, 100};
int main()
{
int N;
while(cin >> N && N > 0)
{
int solved[6];
memset(solved, 0, sizeof(solved));
STUDTYPE stud[N];
for(int i = 0; i < N; ++i)
{
int h, m, s;
scanf(\"%d %d:%d:%d\", &stud[i].solved_num, &h, &m, &s);
stud[i].time = h * 3600 + m * 60 + s;
stud[i].order = i;
solved[stud[i].solved_num]++;
}
sort(stud, stud + N, cmp_by_solve_num);
int first_half[6];
for( int i = 0; i < 6; ++i )
{
if( solved[i] == 1 )
{
first_half[i] = 1;
}
else
{
first_half[i] = solved[i] / 2;
}
}
for( int i = 0; i < N; ++i )
{
int num = stud[i].solved_num;
stud[i].score = default_score[num];
if( first_half[num] > 0 && num < 5 && num > 0 )
{
stud[i].score +=