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 ...
随机推荐
- cin,cout优化
https://www.cnblogs.com/PrayG/p/5749832.html ios_base::sync_with_stdio(0); cin.tie(0); 涨知识了
- js循环给li绑定事件实现和弹出对应的索引
原文:http://www.cnblogs.com/wuchuanlong/p/5945286.html 方法一,动态添加click事件,并添加属性 var itemli = document.get ...
- Jmeter-【beanshell处理器】-获取时间
一.通过操作变量
- ETL工具-Kattle:查询 HTTP/WebService
发送HTTP POST请求,获取返回内容. 发送HTTP GET请求,获取返回内容,可以从前面获取URL.参数名.参数值 通过Restful获取数据 通过webService获取数据 HTTP ...
- smarty基础总结
前提: 1. 部署smarty模板目录: 2. 编写Smarty类的子类,定制好template_dir.compile_dir.config_dir.cache_dir.left_delimiter ...
- bzoj1007题解
[题意分析] 给你n个上半平面,求包含这些上半平面的交的上半平面. [解题思路] 按斜率排序,用单调栈维护一个下凸壳即可.复杂度O(nlog2n). [参考代码] #include <cctyp ...
- [JZOJ 5860] 荒诞
思路: 头皮发麻的操作... 理解一下题意会发现:排名为\(i\)的前缀正好是第\(i\)个前缀. 所以问题就变成了求\(1->len\)的平方和,注意取模即可. #include <bi ...
- flutter 显示base64 图片
后台返回base64 为了本地显示需要转换成Uint8List 1.导入包 import 'dart:convert';2.后台返回base64 格式不被识别需要切分 //'"data:im ...
- python从入门到大神---Python的jieba模块简介
python从入门到大神---Python的jieba模块简介 一.总结 一句话总结: jieba包是分词技术,也就是将一句话分成多个词,有多种分词模型可选 1.分词模块包一般有哪些分词模式(比如py ...
- LeetCode 1103. Distribute Candies to People (分糖果 II)
题目标签:Math 题目让我们分发糖果,分的糖果从1 开始依次增加,直到分完. for loop可以计数糖果的数量,直到糖果发完.但是还是要遍历array 给people 发糖,这里要用到 index ...