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?mid−term??>G?final??, or G?final?? will be taken as the final grade G. Here G?mid−term?? 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?mid−term??‘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?mid−term?? 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 }

原文地址:https://www.cnblogs.com/zllwxm123/p/11296137.html

时间: 2024-08-30 11:37:11

1137 Final Grading (25 分)的相关文章

PAT-1137. Final Grading (25)

1137. Final Grading (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue For a student taking the online course "Data Structures" on China University MOOC (http://www.icourse163.org/), to be qualified for a certificate, he/sh

PAT 1137 Final Grading

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

PAT 甲级 1137 Final Grading

https://pintia.cn/problem-sets/994805342720868352/problems/994805345401028608 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 ob

1137 Final Grading

题意:排序题. 思路:通过unordered_map来存储考生姓名与其成绩信息结构体的映射,成绩初始化为-1,在读入数据时更新各个成绩,最后计算最终成绩并把符合条件的学生存入vector,再排序即可.需要注意的是,计算最终成绩时记得"G must be rounded up to an integer".关于取整函数,总结在这里. 代码: #include <iostream> #include <string> #include <unordered_m

1012 The Best Rank (25)(25 分)

1012 The Best Rank (25)(25 分) To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algebra), and E - English. At the mean ti

1109 Group Photo (25 分)

1109 Group Photo (25 分) Formation is very important when taking a group photo. Given the rules of forming K rows with N people as the following: The number of people in each row must be N/K (round down to the nearest integer), with all the extra peop

1025 PAT Ranking (25 分)

1025 PAT Ranking (25 分) Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists will be merged immediately

1012 The Best Rank (25分) vector与结构体排序

1012 The Best Rank (25分) To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mathematics (Calculus or Linear Algrbra), and E - English. At the mean time, w

4-9 二叉树的遍历 (25分)

4-9 二叉树的遍历   (25分) 输出样例(对于图中给出的树): Inorder: D B E F A G H C I Preorder: A B D F E C G H I Postorder: D E F B H G I C A Levelorder: A B C D F G I E H 代码:(都是遍历的算法) 1 // 4-9 二叉树的遍历 2 // 3 // Created by Haoyu Guo on 04/02/2017. 4 // Copyright ? 2017 Haoy