Hangzhou Electric oj--1084 What is Your Grade?

Source: Internet
Author: User
Tags int size
What is Your Grade?
Problem Description "Point, point, life of student!"
This is a ballad (ballad) Well known in colleges, and your must care about your score in this exam too. How many points can get? Now, I told you the rules which is used in this course.
There is 5 problems in this final exam. And I'll give points if you can solve all 5 problems; Of course, it is fairly difficulty for many. If you can solve 4 problems, you can also get a high score or all (you can get the former (former) only when your rank was in The first half of all students who solve 4 problems). Analogically (etc.), you can get 85, 80, 75, 70, 65, 60. But you won't pass this exam if you solve nothing problem, and I'll mark your score with 50.
Note, only 1 student would get the score when 3 students has solved 4 problems.
I wish you can pass the exam!
Come on!

Input input contains multiple test cases. Each test case is 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, which has been solved) and T (consumed time). You can assume this all data is different when 0<p.
A test case is 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 are 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
Author LCY topic is not very difficult, pay attention to the output format there are some other things to do. The program I wrote below seems a bit long, but it is clear, make a point of looking. For a long time did not write, practice practiced hand.
#include <iostream> #include <algorithm> using namespace std;

const int SIZE = 101;   typedef struct/* struct, used to store input data */{int solved;  /* Number of problem solving */int located;  /* Student's position */int H, m, s;      /* Time spent */INT SOC;

/* Final results */}time;
	BOOL CMP (Time &bi1, Time &bi2)/* Comparison function, used to sort */{if (Bi1.h > Bi2.h) return false;
	else if (Bi1.h < bi2.h) return true;
	   else {if (bi1.m > BI2.M) return false;
	   else if (BI1.M < BI2.M) return true;
	       else {if (Bi1.s > Bi2.s) return false;
	   else if (Bi1.s < BI2.S) return true;
	}}} int main () {int num;
	Time Stu[size];
	Time Sortarr[4][size];
	int p, q, R, K, I;
		while (CIN >> num) && (num >= 0)) {p = q = r = k = 0;
			for (i = 0; i < num; i++) {cin >> stu[i].solved;
			scanf ("%d:%d:%d", &stu[i].h, &AMP;STU[I].M, &AMP;STU[I].S);  stu[i].located = i; /* Record the position of the input *//////////////////////////////////////////////////////////, then do the processing * * if (stu[i].solved = = 5) {STU[I].SOC = 100;
				} if (stu[i].solved = = 4) {Sortarr[0][p] = Stu[i];
			p++;
				} if (stu[i].solved = = 3) {Sortarr[1][q] = Stu[i];
			q++;
				} if (stu[i].solved = = 2) {Sortarr[2][r] = Stu[i];
			r++;
				} if (stu[i].solved = = 1) {Sortarr[3][k] = Stu[i];
			k++;
			} if (stu[i].solved = = 0) {Stu[i].soc = 50;  }} if (P >= 1) {sort (sortarr[0], sortarr[0] + p, CMP);
			/* First sort, according to the time-consuming order from small to large */for (i = 0; i < P/2; i++)/* First half high score */{STU[SORTARR[0][I].LOCATED].SOC = 95;
			} for (; i < P; i++)///lower half of * * * {STU[SORTARR[0][I].LOCATED].SOC = 90;
			}}/* below like */if (q >= 1) {sort (sortarr[1], sortarr[1] + q, CMP);
			for (i = 0; i < Q/2; i++) {STU[SORTARR[1][I].LOCATED].SOC = 85;
			} for (; i < q; i++) {STU[SORTARR[1][I].LOCATED].SOC = 80; }} if (r >= 1) {sort (sortarr[2], soRTARR[2] + R, CMP);
			for (i = 0; i < R/2; i++) {STU[SORTARR[2][I].LOCATED].SOC = 75;
			} for (; I < R; i++) {STU[SORTARR[2][I].LOCATED].SOC = 70;
			}} if (k >= 1) {sort (sortarr[3], sortarr[3] + K, CMP);
			for (i = 0; i < K/2; i++) {STU[SORTARR[3][I].LOCATED].SOC = 65;
			} for (; i < K; i++) {STU[SORTARR[3][I].LOCATED].SOC = 60;
		}} for (i = 0; i < num; i++) {cout << stu[i].soc << Endl;
	} cout << Endl;
	} system ("Pause");
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.