Pid16/who gets the maximum Scholarship
Type: analog source
Noip2005 raise Group
Description
The practice of a school is to grant a scholarship after the final exam of each semester. There are a total of five scholarships, with different conditions:
1) Academician scholarship, 8000 yuan per person, with an average score higher than 80 points (> 80) at the end of the semester. All students who have published one or more papers within the Semester can obtain the scholarship;
2) 4000 scholarship, yuan for each student, with an average score higher than 85 (> 85) at the end of the course, and a score higher than 80 (> 80) for the class evaluation;
3) excellent score: 2000 yuan per person. Students with an average score higher than 90 points (> 90) at the end of the period can receive the prize;
4) Western scholarship, 1000 yuan for each student, with an average score higher than 85 (> 85) at the end of the period;
5) the class Contribution Award is RMB 850 per person. Student cadres with class evaluation scores higher than 80 points (> 80) can receive the award;
If you meet the conditions, you can receive an award. There is no limit on the number of winners of each scholarship. Each student can also receive multiple scholarships at the same time. For example, if Yao Lin's average final score is 87, his class evaluation score is 82, and he is also a student cadre, then he can receive the scholarship and class Contribution Award at the same time, the total prize is 4850 yuan.
Now we provide related data for a number of students. calculate the total number of students that receive the highest prize (assuming that there are always students who can meet the scholarship criteria ).
Input Format
The first line is an integer N (1 <=n <= 100), indicating the total number of students. In the next n rows, each row contains the data of a student. The data is name, average score at the end of the period, class evaluation score, student cadre, and Western Province respectively, and the number of published papers. The name is a string of no more than 20 characters (excluding spaces) consisting of uppercase and lowercase English letters. The average score at the end of the period and the score for class evaluation are all integers (including 0 and 100) between 0 and 100 ); A single character is used for student cadres and a student in a western province respectively. y indicates yes, N indicates no, and the number of published papers is an integer ranging from 0 to 10 (including 0 and 10 ). Each two adjacent data items are separated by a space.
Output Format
The output includes three rows. The first row is the name of the student who receives the most prizes, and the second row is the total number of bonuses received by the student. If two or more students receive the most prizes, the first student's name appears in the input file. The third row is the total number of scholarships received by the N students.
Sample Input
7
Lwher 2147483647 0 y n 10
Hzwer 2147483647 499 y n 9
Ndsf 100 499 Y 0
Jjs 100 499 N 1
Zhber 100 2147483647 y n 0
Jams 100 2147483647 y n 0
Chenzeyu 9999 99 N 10
Sample output
Hzwer
14850
74400
Ideas
This question really has no meaning...
It should be noted that after reading the online processing, all kinds of information do not need to be saved. Although it does not matter if it is a waste of space, it is not okay after all ....
When I wrote it with PAS, my heart was abused. The CIN of C ++ was an artifact... Cin> STR read the space just right...
Code and Result
#include<iostream>#include<cstdlib>#include<cstdio>using namespace std;string name;int mark,work,article;char west,cadres;string bestname;int bestmoney,allmoney;int n;int main(){ cin>>n; for (int i=1;i<=n;i++) { int money=0; cin>>name; cin>>mark>>work; cin>>cadres>>west; cin>>article; if ( (mark>80)&&(article>=1) ) money+=8000; if ( (mark>85)&&(work>80) ) money+=4000; if ( (mark>90) ) money+=2000; if ( (mark>85)&&(west==‘Y‘) ) money+=1000; if ( (work>80)&&(cadres==‘Y‘) ) money+=850; if (money>bestmoney) { bestmoney=money; bestname=name; } allmoney+=money; } cout<<bestname<<endl; cout<<bestmoney<<endl; cout<<allmoney<<endl; return 0;}
C ++ result
// ================================================ ======================================
program ss; var i,exam,class,n,c,j,word,money,bestmoney,all:longint; ch,office,west:char; name,key,g,bestname:string; begin readln(n); for i:=1 to n do begin money:=0; readln(key); j:=1; name:=‘‘; while key[j]<>‘ ‘ do begin name:=name+key[j]; j:=j+1; end; j:=j+1; exam:=0; while key[j]<>‘ ‘ do begin exam:=exam*10+(ord(key[j])-ord(‘0‘)); j:=j+1; end; j:=j+1; class:=0; while key[j]<>‘ ‘ do begin class:=class*10+(ord(key[j])-ord(‘0‘)); j:=j+1; end; office:=key[j+1]; west:=key[j+3]; j:=j+5; word:=ord(key[j])-ord(‘0‘); if ((exam>80) and (word>=1)) then money:=money+8000; if ((exam>85) and (class>80)) then money:=money+4000; if (exam>90) then money:=money+2000; if ((exam>85) and (west=‘Y‘)) then money:=money+1000; if ((class>80) and (office=‘Y‘)) then money:=money+850; if money>bestmoney then begin bestname:=name; bestmoney:=money; end; all:=all+money; end; writeln(bestname); writeln(bestmoney); writeln(all);end.
Pascalpas results
I always think that PAS was written in the past. Why is it faster than my c ++ !!!
[Water] noip2005 raise the group who received the most scholarship