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 G=(G​mid−term​​×40%+G​final​​×60%) 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 "−1" 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

#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
struct Node{
string name;
int gp,gm,gf,g;
}node; bool cmp(Node a,Node b){
return a.g != b.g ? a.g > b.g : a.name < b.name;
} int main(){
int p,m,n;
scanf("%d%d%d",&p,&m,&n);
vector<Node> stu,ans;
map<string,int> idx;
string s;
int cnt = ,score;
for(int i = ; i < p; i++){
cin >> s >> score;
if(score >= ){
node.name = s;
node.gp = score;
node.gm = node.gf = -;
node.g = ;
stu.push_back(node);
idx[s] = cnt++;
}
}
for(int i = ; i < m; i++){
cin >> s >> score;
if(idx[s] != ){
stu[idx[s]-].gm = score;
}
}
for(int i = ; i < n; i++){
cin >> s >> score;
if(idx[s] != ){
int temp = idx[s] - ;
stu[temp].gf = score;
stu[temp].g = score;
if(stu[temp].gm > score){
stu[temp].g = (int)(stu[temp].gm*0.4+stu[temp].gf*0.6+0.5);
}
}
}
for(int i = ; i < stu.size(); i++){
if(stu[i].g >= ) ans.push_back(stu[i]);
}
sort(ans.begin(),ans.end(),cmp);
for(int i = ; i < ans.size(); i++){
cout << ans[i].name;
printf(" %d %d %d %d\n",ans[i].gp,ans[i].gm,ans[i].gf,ans[i].g);
}
return ;
}

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

  1. PAT 1137 Final Grading[一般][排序]

    1137 Final Grading(25 分) For a student taking the online course "Data Structures" on China ...

  2. PAT 甲级 1137 Final Grading

    https://pintia.cn/problem-sets/994805342720868352/problems/994805345401028608 For a student taking t ...

  3. PAT 1137 Final Grading

    For a student taking the online course "Data Structures" on China University MOOC (http:// ...

  4. 1137 Final Grading

    题意:排序题. 思路:通过unordered_map来存储考生姓名与其成绩信息结构体的映射,成绩初始化为-1,在读入数据时更新各个成绩,最后计算最终成绩并把符合条件的学生存入vector,再排序即可. ...

  5. PAT_A1137#Final Grading

    Source: PAT A1137 Final Grading (25 分) Description: For a student taking the online course "Dat ...

  6. PAT 乙级 1080 MOOC期终成绩 (25 分)

    1080 MOOC期终成绩 (25 分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分的 ...

  7. 1109 Group Photo (25 分)

    1109 Group Photo (25 分) Formation is very important when taking a group photo. Given the rules of fo ...

  8. 1012 The Best Rank (25 分)

    1012 The Best Rank (25 分) To evaluate the performance of our first year CS majored students, we cons ...

  9. A1012 The Best Rank (25)(25 分)

    A1012 The Best Rank (25)(25 分) To evaluate the performance of our first year CS majored students, we ...

随机推荐

  1. 在Windows里定时执行一个Python文件

    一.系统环境 操作系统:Win7 64位 二.说明 1.建立一个dos批处理文件 例: @echo off C: cd C:\work\python python aaa.py exit 2.利用Wi ...

  2. solr第二天 京东案例 课程文档 有用

    全文检索技术   Lucene&Solr               Part3 1. 课程计划 1. Solr配置中文分析器 a) Schema.xml的配置 b) 配置IKAnalyzer ...

  3. 面试题--CVTE

    2.HashMap和HashSet的实现原理,hashset 和hashMap区别 HashSet底层就是HashMap实现的, *HashMap* *HashSet* HashMap实现了Map接口 ...

  4. ROS naviagtion analysis: costmap_2d--Costmap2DROS

    博客转载自:https://blog.csdn.net/u013158492/article/details/50485418 在上一篇文章中moveBase就有关于costmap_2d的使用: pl ...

  5. MFC可视化

    当你修改了变量的值,而希望对话框控件更新显示,就应该在修改变量后调用UpdateData(FALSE):如果你希望知道用户在对话框中到底输入了什么,就应该在访问变量前调用UpdateData(TRUE ...

  6. hdu 4278 Faulty Odometer(进制转换)

    十进制转八进制的变形: #include<stdio.h> int main() { int n; while(scanf("%d",&n)!=EOF& ...

  7. mvc全局过滤器和httpmodule的执行顺序

    根据http管线模型,请求先通过httpmodule,再通过httphandler,之后再进入mvc的过滤器 另外参考:MVC如何在Pipeline中接管请求的? http://www.cnblogs ...

  8. HDU 4803 Poor Warehouse Keeper(贪心)

    题目链接 题意 :屏幕可以显示两个值,一个是数量x,一个是总价y.有两种操作,一种是加一次总价,变成x,1+y:一种是加一个数量,这要的话总价也会相应加上一个的价钱,变成x+1,y+y/x.总价显示的 ...

  9. 文字相对于 div 垂直居中

    通用方法 height  跟line-height div{ border: 1px solid black; text-align: left; height: 200px; line-height ...

  10. strcmp返回值布尔类型的判断

    strcmp: 用于比较两个字符串,原型如下: int strcmp ( char const *s1, char const *s2):如果s1小于s2,strcmp函数返回一个小于零的值.如果s1 ...