Hdoj1084 what is your grade?

Source: Internet
Author: User

What is your grade? Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others) Total submission (s): 8302 accepted submission (s): 2547

Problem description "point, point, life of Student !"
This is a balglad (Song) 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 your. if you can solve 4 problems, you can also get a high score 95 or 90 (you can get the former (former) only when your rank is in the first half of all students who solve 4 problems ). analogically (and so on), 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!
 
Inputinput 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 shocould not to be processed.
 
Outputoutput 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
This is the first time that WAF has been sweating for 9 times.

#include <cstdio>#include <algorithm>using std::sort;struct Node{int pos, num, s, val;} stu[102];int arr[6];bool cmp1(Node a, Node b){if(a.num == b.num) return a.s < b.s;return a.num > b.num;}bool cmp2(Node a, Node b){return a.pos < b.pos;}int main(){int n, h, m, s, num;while(scanf("%d", &n) == 1 && n > 0){for(int i = 1; i < 6; ++i) arr[i] = 0;for(int i = 0; i < n; ++i){scanf("%d %d:%d:%d", &num, &h, &m, &s);s += m * 60 + h * 3600;stu[i].pos = i;stu[i].num = num;stu[i].s = s;stu[i].val = 100 - (5 - num) * 10;++arr[num];}sort(stu, stu + n, cmp1);for(int i = 4, pos = 0; i; --i){if(arr[i]){while(stu[pos].num != i) ++pos;if(arr[i] == 1) stu[pos++].val += 5;for(int j = 0; j < arr[i] / 2; ++j)stu[pos++].val += 5;}}sort(stu, stu + n, cmp2);for(int i = 0; i < n; ++i)printf("%d\n", stu[i].val);printf("\n");}return 0;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.