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. Hibernate和Mybatis区别 详细 有用

    1.开发上手难度 hibernate的真正掌握(封装的功能和特性非常多)要比Mybatis来得难. 在真正产品级应用上要用Hibernate,不仅对开发人员的要求高,hibernate往往还不适合(多 ...

  2. Spring 实例化bean的三种方式

    第一种方法:直接配置Bean <bena id="所需要实例化的一个实例名称" class="包名.类名"/> 例如: 配置文件中的bean.XML ...

  3. SOAP UI

    We use SoapUI-Pro-5.1.2 1. Basic introduction - Windows 2. Use project environment tab to manage the ...

  4. PC建立WIFI热点

    netsh wlan set hostednetwork ssid=test key =12345678netsh wlan start hostednetwork

  5. easyUI form sumit 中文乱码

    jsp 编码方式: pageEncoding="UTF-8" tomcat 编码方式: <Connector connectionTimeout="20000&qu ...

  6. angular 响应式表单

  7. this指针------新标准c++程序设计

    背景:   c++是在c语言的基础上发展而来的,第一个c++的编译器实际上是将c++程序翻译成c语言程序,然后再用c语言编译器进行编译.c语言没有类的概念,只有结构,函数都是全局函数,没有成员函数.翻 ...

  8. could not read data from '/Users/lelight/Desktop/ViewControllerLife/ViewControllerLife/Info.plist': The file “Info.plist” couldn’t be opened because there is no such file.

    1.Info.plist放置至新文件夹下,路径被修改了,报错. could not read data from '/Users/lelight/Desktop/ViewControllerLife/ ...

  9. Redis在window下安装以及配置

    一.安装Redis 1.Redis官网下载地址:http://redis.io/download,下载相应版本的Redis,在运行中输入cmd,然后把目录指向解压的Redis目录. 2.启动服务命令 ...

  10. kali linux之本地提权

    已实现本地低权限帐号登录,希望获取更高权限,实现对目标进一步控制 系统帐号之间权限隔离(操作系统安全的基础,用户空间,内核空间) 系统帐号(用户帐号登录时获取权限令牌,服务帐号无需用户登录已在后台启动 ...