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
 #include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
struct Node
{
string name;
int Gp = -, Gmid = -, Gfinal = -, G;//之所以不给-1,方便后面相加不用判断
};
int p, m, n;
unordered_map<string, int>nameID;
vector<Node>students;
int main()
{
int score;
string name;
cin >> p >> m >> n;
while (p--)
{
cin >> name >> score;
if (score < )//小于200的不要
continue;
nameID[name] = students.size();
students.push_back(Node{ name,score,-,-, });
}
while (m--)
{
cin >> name >> score;
if (nameID.find(name) != nameID.end())//无记录的不要
students[nameID[name]].Gmid = score;
}
while (n--)
{
cin >> name >> score;
if (nameID.find(name) != nameID.end())//无记录的不要
students[nameID[name]].Gfinal = score;
}
for (int i = ; i < students.size(); ++i)
{
if (students[i].Gfinal > students[i].Gmid)
students[i].G = students[i].Gfinal;
else
students[i].G = round(students[i].Gmid*0.4 + students[i].Gfinal*0.6);
}
sort(students.begin(), students.end(), [](Node a, Node b)
{
if (a.G == b.G)
return a.name < b.name;
else
return a.G > b.G;
});
for (auto v : students)
if (v.Gp >= && v.G >= )
cout << v.name << " " << v.Gp << " " << v.Gmid << " " << v.Gfinal << " " << v.G << endl;
return ;
}

最新文章

  1. 一枚招聘信息——分期乐招页面重构/UI开发(8k-12k 深圳 经验1-3年 学历不限 全职)
  2. JAVA 多线程随笔 (一) 可见性和volatile关键字
  3. C, C#, AS3的变量
  4. SVN cleanup操作反复失败解决办法
  5. VC++打开对话框选择一个文件夹路径 BROWSEINFO结构
  6. spring 占位符 默认值
  7. Word两端对齐问题
  8. [CSS] :not Selector
  9. MT4 做指标模版
  10. js面向对象总结
  11. Spring Resource接口获取资源
  12. Spring配置从配置文件读取属性值
  13. Centos 5 无法使用ifconfig命令
  14. setuid setgid
  15. php框架中,try,catch不能用的问题(转载)
  16. 如何使用ffmpeg
  17. JVM系列三:JVM参数设置
  18. How To Join XLA_AE_HEADERS and RCV_TRANSACTIONS(子分类账到事务处理追溯)
  19. Sigar简介
  20. word2vec入门理解的博客整理

热门文章

  1. FastStone Capture 文件名设置小记录
  2. List之去重
  3. Android中的APK,TASK,PROCESS,USERID之间的关系
  4. LUOGU P4560 [IOI2014]Wall 砖墙 (线段树)
  5. dcoker安装redis
  6. NX二次开发-UFUN获取环境变量路径,将环境变量转换为字符串,字符串拼接UF_translate_variable
  7. vue webpack打包后.css文件里面的背景图片路径错误解决方法
  8. Spring-Security (学习记录三)--读取数据库中的用户和角色
  9. Soldier and Number Game-素数筛
  10. JQuery AJAX 通过一般处理程序 取列表