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 0Output
Output the scores of N students in N lines for each case, and there is a blank line after each case.Sample Input
45 06:30:17
4 07:31:27
4 08:12:12
4 05:23:13
1
5 06:30:17
-1
Sample Output
10090
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"); } }
相关文章推荐
- 1100 - Again Array Queries (鸽笼定理)
- 多线程学习——python脚本批量修改华为交换机端口配置
- Android Studio新手经验
- Ali-Wax使用和源码解析系列-Wax的集成和调试环境搭建
- zabbix梯度告警
- mybatis执行批量更新batch update 的方法
- ios 开发中遇到的一些问题
- nankai100_3
- 解决ScrollView或ListView中嵌套ListView引起的冲突
- MySqlhq语句拼接时间查询
- php强制下载文件、文件强制下载、输出强制下载
- HIHOCODER#1096 : Divided Product
- servlet request getHeader(“x-forwarded-for”) 获取真实IP
- 阻止冒泡事件
- tomcat7.0.27的bio,nio.apr高级运行模式(转)
- asp.net简单生成验证码的方法
- C++中引用(&)的用法和应用实例
- 关于Spring Transaction的笔记
- poj 1930 Dead Fraction 数学 分数 无限循环小数
- 硕士论文格式设置过程