您的位置:首页 > 其它

HDU ACM 1084 What Is Your Grade?

2015-11-25 11:47 465 查看

原题描述

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

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

解题思路

题意:和ACM选修课期末考试情况差不多。。有5道题,做对1道60分,每多对1道+10分,做对0道50分。

如果做对的时间在相同做对道数的学生中是前一半的,那+5分。按输入学生的顺序输出每个学生的分数。

构造学生结构体,其中有一个tag,记录输入时的顺序,还有point,记录学生的分数。

将学生按照从好到差排序,然后遍历将分数赋给point。

要用一个数组储存做对每道题的人数,判断是否+5分。

输出时还要按照tag重新排序输出

参考代码

#include <iostream>
#include <algorithm>
using namespace std;

struct stu
{
int tag, solved, time, point;
}S[102];
int TI[6];                  // 解决x道题的人数

bool cmp1(stu a,stu b)      // 最好的学生排前面
{
if (a.solved == b.solved)
return a.time < b.time;
return a.solved > b.solved;
}

bool cmp2(stu a,stu b)      // 按照输入的顺序重新排序
{
return a.tag < b.tag;
}

int main()
{
// freopen("in.txt", "r", stdin);
int n, h, m, s;
while(~scanf("%d",&n))
{
if (n < 0) break;
memset(TI, 0, sizeof(TI));
for (int i = 0; i < n;i++)
{
scanf("%d%d:%d:%d", &S[i].solved, &h, &m, &s);
S[i].time = h * 3600 + m * 60 + s;
S[i].tag = i;
TI[S[i].solved]++;
}
sort(S, S + n, cmp1);
int temp[5];
memset(temp, 0,sizeof(temp));
for (int i = 0; i < n;i++)
{
if (S[i].solved == 5)
S[i].point = 100;
else if (S[i].solved == 0)
S[i].point = 50;
else
{
temp[S[i].solved]++;
S[i].point = S[i].solved * 10 + 50;
if (temp[S[i].solved] <= TI[S[i].solved] / 2)       // 如果是前半部完成的,加5分
S[i].point += 5;
}
}
sort(S, S + n, cmp2);
for (int i = 0; i < n;i++)
{
printf("%d\n", S[i].point);
}
printf("\n");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: