What Is Your Grade?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13212 Accepted Submission(s): 4236
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
问题链接:HDU1084 What Is Your Grade?
问题描述:(略)
问题分析:
这个题的关键是按照做题数量和完成时间计算得分,需要排序。排序后按照题意计算即可。输出结果时,需要按照原来的输入顺序输出得分,所以事先分配ID是必要的。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C++语言程序如下:
/* HDU1084 What Is Your Grade? */
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
const int P = 5;
int sum[P + 1], tot[P + 1];
const int N = 100;
struct Node {
int id; // 原始编号
int num; // 解题数量
int time; // 使用时间
int score; // 分数
} a[N];
bool cmp(Node a, Node b)
{
return (a.num == b.num) ? a.time < b.time : a.num > b.num;
}
bool cmp2(Node a, Node b)
{
return a.id < b.id;
}
int main()
{
int n;
while(~scanf("%d", &n) && n >= 0) {
memset(sum, 0, sizeof(sum));
memset(tot, 0, sizeof(tot));
int h, m, s;
for(int i = 0; i < n; i++) {
scanf("%d %d:%d:%d", &a[i].num, &h, &m, &s);
a[i].id = i;
a[i].time = h * 3600 + m * 60 + s;
sum[a[i].num]++;
}
for(int i = P - 1; i > 0; i--)
tot[i] = tot[i + 1] + sum[i + 1];
sort(a, a + n, cmp);
for(int i = 0; i < n; i++) {
a[i].score = a[i].num * 10 + 50;
if(a[i].num >= 1 && a[i].num < P && (((i + 1) - tot[a[i].num]) <= sum[a[i].num] / 2))
a[i].score += 5;
}
sort(a, a + n, cmp2);
for(int i = 0; i < n; i++)
printf("%d\n", a[i].score);
printf("\n");
}
return 0;
}