PAT甲级——A1137 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 Gmid−term>Gfinal, or Gfinal will be taken as the final grade G. Here Gmid−term and Gfinal 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 Gp's; the second one contains M mid-term scores Gmid−term's; and the last one contains N final exam scores Gfinal'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
Gp Gmid−term Gfinal 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 ;
}
PAT甲级——A1137 Final Grading【25】的更多相关文章
- PAT 甲级 1137 Final Grading
https://pintia.cn/problem-sets/994805342720868352/problems/994805345401028608 For a student taking t ...
- 【PAT甲级】1070 Mooncake (25 分)(贪心水中水)
题意: 输入两个正整数N和M(存疑M是否为整数,N<=1000,M<=500)表示月饼的种数和市场对于月饼的最大需求,接着输入N个正整数表示某种月饼的库存,再输入N个正数表示某种月饼库存全 ...
- PAT A1137 Final Grading (25 分)——排序
For a student taking the online course "Data Structures" on China University MOOC (http:// ...
- A1137. Final Grading
For a student taking the online course "Data Structures" on China University MOOC (http:// ...
- PAT甲级 1130. Infix Expression (25)
1130. Infix Expression (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Give ...
- PAT甲级 1122. Hamiltonian Cycle (25)
1122. Hamiltonian Cycle (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue The ...
- PAT甲级 1121. Damn Single (25)
1121. Damn Single (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue "Dam ...
- PAT甲级 1126. Eulerian Path (25)
1126. Eulerian Path (25) 时间限制 300 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue In grap ...
- PAT甲级 1129. Recommendation System (25)
1129. Recommendation System (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue ...
随机推荐
- js面向对象的几种方式----工厂模式、构造函数模式、原型模式
对象的字面量 var obj={} 创建实例对象 var obj=new Object() 工厂模式 function cPerson(name,sex,age){ var o = new Objec ...
- SpringMVC 拦截器原理
前言 SpringMVC 拦截器也是Aop(面向切面)思想构建,但不是 Spring Aop 动态代理实现的, 主要采用责任链和适配器的设计模式来实现,直接嵌入到 SpringMVC 入口代码里面. ...
- C# 与 C/C++ 网络传输字符串解决方案
{ 不管你的数据加没加密,只要有中文,请转16进制后再处理,把16进制再转为GB2312的byte再发送, 接收的话同样 c++ 发送时转16进制再发送,c#16进制转字符串后再转GB2312就可以了 ...
- 矩阵乘法分配律+bitset优化——hdu4920
因为是模3,所以把原矩阵拆成两个01矩阵,然后按分配律拆开分别进行矩阵乘法,行列用bitset来存进行优化即可 注意 int bitset<int>::count() 函数可以统计bits ...
- sqlserver中常用的windows命令行的操作
1.删除指定目录下指定时间之前的文件: ), ), @sqltxtdel varchar(max) --指定的删除时间 set @deldate= '-8' --指定的删除路径 set @bakpat ...
- [转] 如何在vps上安装和登录Xwindows
如何VPS也可以拥有像windows一样图形窗口,这里写个教程,据说xwindows是一个比微软windows还强大的linux图形界面,怎样强大,我也是听说的,你可以自己去试,然后告诉我. vps安 ...
- Python实现字符串与数组相互转换功能示例
Python实现字符串与数组相互转换功能示例 本文实例讲述了Python实现字符串与数组相互转换功能.分享给大家供大家参考,具体如下: 字符串转数组 str = '1,2,3' arr = s ...
- shell 单引号&双引号的使用
使用双引号: shell> X='parameter' shell> echo "Hello $X" Hello parameter 单引号中嵌套单引号: shell& ...
- 【POJ】1860 Currency Exchange
真是气skr人..没把d[]换成double...de了一上午的bug// 记得用G++提交啊 题目链接:http://poj.org/problem?id=1860 题意:告诉你n个点,m条路.起始 ...
- mysql实现访问审计
mysql的连接首先都是通过init_connect初始化,然后连接到实例. 我们利用这一点,通过在init_connect的时候记录下用户的thread_id,用户名和用户地址实现db的访问审计功能 ...