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. while循环for循环优缺点和应用

    while循环常用于那种不知道循环次数是多少的情况,比如让用户循环输入一个整数,直到输入某个特殊的字符为止,你根本没法直到这个循环会进行的次数. for循环多用于循环次数比较明确的情况,比如for(n ...

  2. Process management of windows

    igfxem.exe进程是正常的进程.是intel家的核显驱动类的进程.核显即"核芯显卡",是指GPU部分它是与CPU建立在同一内核芯片上,两者完全融合的芯片."核芯显卡 ...

  3. Apache htdigest命令

    一.简介 htdigest命令是Apache的Web服务器内置工具,用于创建和更新储存用户名.域和用于摘要认证的密码文件.服务器上的资源可以被限制为仅允许由htdigest建立的文件中的用户访问.使用 ...

  4. 学习PDO啦

    通过查找资料对PDO有了一定的了解,PDO(PHP Data Object )为PHP数据对象,为PHP访问数据库提供了一个轻量级的借口,但PDO本生不能实现访问数据库的任何功能,只能通过数据库的PD ...

  5. Git安装和常用命令

    Git是目前世界上最先进的分布式版本控制系统!!! Git能自动帮我们记录每次文件的改动,还可以让同事协作编辑. 接下来,简单的介绍下Git的安装和常用命令: Git安装: 1.Windows系统,进 ...

  6. Linux下安装memcache PHP扩展

    [root@centos memcache-2.2.4]# wget http://pecl.php.net/get/memcache-2.2.4.tgz [root@centos memcache- ...

  7. c#并发编程经典实例文摘

    第1章 并发编程概述 1.1 并发编程简介 并发: 多线程(包括并行处理) 异步编程(异步操作)程序启动一个操作,而该操作将会在一段时间后完成 响应时编程(异步事件)可以没有一个实际的开始,可以在任何 ...

  8. centos 升级 python

    1. 下载python 2.7编译安装 $wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz $tar zxvf Python-. ...

  9. ParameterizedType的作用

    public interface ParameterizedType  extends Type subParam.Java package com.example.test; public clas ...

  10. SQL Server 2012自动备份

    SQL 2012和2008一样,都可以做维护计划,来对数据库进行自动的备份. 现在做这样一个数据库维护的计划,每天0点对数据库进行差异备份,每周日0点对数据库进行完全备份,并且每天晚上10点删除一次过 ...