1137 Final Grading (25 分)

Posted #忘乎所以#

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1137 Final Grading (25 分)相关的知识,希望对你有一定的参考价值。

1137 Final Grading (25 分)
 

For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/she must first obtain no less than 200 points from the online programming assignments, and then receive a final grade no less than 60 out of 100. The final grade is calculated by 0 if G?midterm??>G?final??, or G?final?? will be taken as the final grade G. Here G?midterm?? and G?final?? are the student‘s scores of the mid-term and the final exams, respectively.

The problem is that different exams have different grading sheets. Your job is to write a program to merge all the grading sheets into one.

Input Specification:

Each input file contains one test case. For each case, the first line gives three positive integers: P , the number of students having done the online programming assignments; M, the number of students on the mid-term list; and N, the number of students on the final exam list. All the numbers are no more than 10,000.

Then three blocks follow. The first block contains P online programming scores G?p??‘s; the second one contains M mid-term scores G?midterm??‘s; and the last one contains N final exam scores G?final??‘s. Each score occupies a line with the format: StudentID Score, where StudentID is a string of no more than 20 English letters and digits, and Score is a nonnegative integer (the maximum score of the online programming is 900, and that of the mid-term and final exams is 100).

Output Specification:

For each case, print the list of students who are qualified for certificates. Each student occupies a line with the format:

StudentID G?p?? G?midterm?? G?final?? G

If some score does not exist, output "−" instead. The output must be sorted in descending order of their final grades (G must be rounded up to an integer). If there is a tie, output in ascending order of their StudentID‘s. It is guaranteed that the StudentID‘s are all distinct, and there is at least one qullified student.

Sample Input:

6 6 7
01234 880
a1903 199
ydjh2 200
wehu8 300
dx86w 220
missing 400
ydhfu77 99
wehu8 55
ydjh2 98
dx86w 88
a1903 86
01234 39
ydhfu77 88
a1903 66
01234 58
wehu8 84
ydjh2 82
missing 99
dx86w 81

Sample Output:

missing 400 -1 99 99
ydjh2 200 98 82 88
dx86w 220 88 81 84
wehu8 300 55 84 84
 
也就是个模拟题,挺简单了。
 
 1 #include <bits/stdc++.h>
 3 using namespace std;
 4 int n,m,k;
 5 string s;
 6 double an;
 7 struct Node{
 8     string st;
 9     double assign;
10     double mid, final;
11     int g;
12     friend bool operator < (const Node &a, const Node &b){
13         return a.g==b.g?(a.st+b.st)<(b.st+a.st):a.g>b.g;
14     }
15 }node[10006];
16 int pos = 0;
17 map<string,int> mp;
18 int main(){
19     cin >> n >> m >> k;
20     for(int i = 0 ; i < n; ++i){
21         cin >> s >> an;
22         if(an < 200) continue;
23         mp[s] = ++pos;
24         node[pos].st = s;
25         node[pos].assign = an;
26         node[pos].mid = node[pos].final = node[pos].g = -1;
27     }
28     for(int i = 0 ; i < m; ++i){
29         cin >> s >> an;
30         if(mp[s] != 0){
31             int ans = mp[s];
32             node[ans].mid = an;
33         }
34     }
35     for(int i = 0 ; i < k; ++i){
36         cin >> s >> an;
37         if(mp[s] != 0){
38             int ans = mp[s];
39             node[ans].final = an;
40             if(node[ans].assign >= 200){
41                 if(node[ans].mid > node[ans].final){
42                     node[ans].g = int(node[ans].mid*0.4+node[ans].final*0.6+0.5);
43                 }else{
44                     node[ans].g = int(node[ans].final);
45                 }
46             }
47         }
48     }
49     sort(node+1,node+pos+1);
50     for(int i = 1; i <= pos; ++i){
51         if(node[i].g >= 60){
52             cout<<node[i].st<<" "<<node[i].assign<<" "<<node[i].mid<<" "<<node[i].final<<" "<<node[i].g<<endl;
53         }
54     }
57     return 0;
58 }

 

 
 
 
 
 

以上是关于1137 Final Grading (25 分)的主要内容,如果未能解决你的问题,请参考以下文章

1137 Final Grading (25 分)难度: 一般 / 知识点: 排序 哈希表

PAT-1137. Final Grading (25)

1137 Final Grading (25)

PAT 1137 Final Grading

1137 Final Grading

PAT 甲级 1137 Final Grading