HDU1084--What Is Your Grade?
来源:互联网 发布:电子数据交换应用流程 编辑:程序博客网 时间:2024/05/24 01:55
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
45 06:30:174 07:31:274 08:12:124 05:23:1315 06:30:17-1
Sample Output
100909095100
解析:这个题目中有点没有说清楚,当题目的数量只有一个人的时候给予的分数是少的。
贴一下自己的代码,代码写的很长,但是很清楚哈!
#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 LOCALfreopen("input.txt" , "r" , stdin);#endifint 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;}
0 0
- hdu1084(What Is Your Grade?)
- HDU1084:What Is Your Grade?
- Hdu1084 What Is Your Grade?
- HDU1084--What Is Your Grade?
- hdu1084:What is your grade?
- HDU1084 What Is Your Grade?
- hdu1084 What's your grade?
- hdu1084 What Is Your Grade? 结构体的应用
- 【结构体排序】HDU1084 What Is Your Grade?
- What Is Your Grade?
- What Is Your Grade?
- What Is Your Grade?
- what is your grade
- What Is Your Grade?
- What Is Your Grade?
- HDOJ1084 What Is Your Grade?
- hd1084 What Is Your Grade?
- 十二、What Is Your Grade?
- PWM占空比输出均值与DA输出值的区别
- 基本运算符
- Win8系统下载安装应用之后却找不到怎么办
- unity3D游戏开发实战原创视频讲座系列11之相扑游戏开发并发布到Win\WP8
- Android的线程使用来更新UI----Thread、Handler、Looper、TimerTask等
- HDU1084--What Is Your Grade?
- 30岁后你会站在哪里?
- OpenCMS安装
- lightoj 1061 状态压缩DP
- centos6.x下让redis以服务方式运行
- 探索高效jQuery的奥秘
- “什么黑白”上线 APP STORE后的心得(模仿别踩白块、钢琴2)
- 获取datagridview选中行的某咧的值
- java实现快速排序