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 ...
随机推荐
- zepto-touch事件
<!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...
- 14. static(静态) 关键字
1.修饰成员变量 1)定义:数据需要被共享给所有对象使用使用static修饰(全局变量) 2)注意: 1.用static中创建的成员变量在内存中只有一份 2.千万不要为了方便访问数据而使用static ...
- python编写微信公众号首图思路详解
前言 之前一直在美图秀秀调整自己的微信公众号首图,效果也不尽如人意,老是调来调去,最后发出来的图片被裁剪了一大部分,丢失部分关键信息,十分恼火,于是想着用python写一个程序,把微信公众号首图的模式 ...
- VS 2019企业版激活码
Visual Studio 2019 EnterpriseBF8Y8-GN2QH-T84XB-QVY3B-RC4DF
- NX二次开发-bat脚本文件切换NX的环境变量(NX路径和语言)
路径环境变量切换到NX9.bat @echo off setx /M UGII_BASE_DIR "D:\Program Files\Siemens\NX 9.0" ------- ...
- OpenStack与KVM的区别与联系
转:https://www.aliyun.com/zixun/content/2_6_280418.html OpenStack与KVM都是目前IT界比较热门的两个词汇.它们都是开源的,都与Linux ...
- C++输入cin详解
输入原理: 程序的输入都建有一个缓冲区,即输入缓冲区.一次输入过程是这样的,当一次键盘输入结束时会将输入的数据存入输入缓冲区,而cin函数直接从输入缓冲区中取数据.正因为cin函数是直接从缓冲区取数据 ...
- java系列(1/4)基础阶段-MySQL(2/13)
本单元目标 一.为什么要学习数据库 二.数据库的相关概念 DBMS.DB.SQL 三.数据库存储数据的特点 四.初始MySQL MySQL产品的介绍 MySQL产品的安装 ★ MySQL服务的启动和停 ...
- 利用Python,方便局域网内上传下载文件
因为一直在用windows系统,最近需要用到linux的服务器,两个电脑之间总是需要来回拷贝文件 这样使得很繁琐,之前一直在用Python,开启一个简单的服务器,可以在另外一台同一局域网下的电脑,在线 ...
- 2018-8-10-win10-uwp-在-Canvas-放一个超过大小的元素会不会被裁剪
title author date CreateTime categories win10 uwp 在 Canvas 放一个超过大小的元素会不会被裁剪 lindexi 2018-08-10 19:16 ...