1137 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 G=(Gmid−term×40%+Gfinal×60%) 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 "−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 分)的更多相关文章
- PAT 1137 Final Grading[一般][排序]
1137 Final Grading(25 分) For a student taking the online course "Data Structures" on China ...
- PAT 甲级 1137 Final Grading
https://pintia.cn/problem-sets/994805342720868352/problems/994805345401028608 For a student taking t ...
- PAT 1137 Final Grading
For a student taking the online course "Data Structures" on China University MOOC (http:// ...
- 1137 Final Grading
题意:排序题. 思路:通过unordered_map来存储考生姓名与其成绩信息结构体的映射,成绩初始化为-1,在读入数据时更新各个成绩,最后计算最终成绩并把符合条件的学生存入vector,再排序即可. ...
- PAT_A1137#Final Grading
Source: PAT A1137 Final Grading (25 分) Description: For a student taking the online course "Dat ...
- PAT 乙级 1080 MOOC期终成绩 (25 分)
1080 MOOC期终成绩 (25 分) 对于在中国大学MOOC(http://www.icourse163.org/ )学习“数据结构”课程的学生,想要获得一张合格证书,必须首先获得不少于200分的 ...
- 1109 Group Photo (25 分)
1109 Group Photo (25 分) Formation is very important when taking a group photo. Given the rules of fo ...
- 1012 The Best Rank (25 分)
1012 The Best Rank (25 分) To evaluate the performance of our first year CS majored students, we cons ...
- 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-如何自己在eclipse上配置Andriod环境
转载:http://blog.csdn.net/dr_neo/article/details/49870587 最新鲜最详细的Android SDK下载安装及配置教程 2015年11月16日 19:2 ...
- git 的使用方法
git 的使用有3个主要步骤: 1.1 工作区域操作: 在自己的git账号下构建一个工作目录, 并往工作目录里添加文件内容(cp /root/data/VIP_Amount_prediction/* ...
- 2.Border Layout 自定义一个Layout来完成布局。
目标: 1.添加控件的函数 void QLayout::addWidget ( QWidget * w ) 在这个例子里面我们重载这个函数 void addWidget ( QWidget * w, ...
- wamp安装两个,数据库丢了,怎么办
wampserver3.*下载了好几天一直没有安装,今天发现必须安装,已升级自己的php版本,不过也饿可以自己手动配置PHP版本,既然有安装包就算了吧,当安装完后,发现忘记备份自己的数据库了,幸好之前 ...
- asp.net web 自定义控件
0.调用代码 protected override void Page_Load(object sender, EventArgs e) { //给基类服务接口复制,可不付 if (IsPostBac ...
- Jackson Streaming API to read and write JSON
Jackson supports read and write JSON via high-performance Jackson Streaming APIs, or incremental mod ...
- 请教一个Jquery ligerui 框架的小问题
关闭子窗体时,要刷新父窗体,百度了很多像使用“window.opener.location.reload();”都不行,和easyui框架是有区别的 在子窗体里写Response.Write(&quo ...
- MongoDB整理笔记の管理Replica Sets
一.读写分离 从库能进行查询,这样可以分担主库的大量的查询请求. 1.先向主库中插入一条测试数据 [root@localhost bin]# ./mongo --port 28010 MongoD ...
- Android Canvas的save(),saveLayer()和restore()浅谈
save() saveLayer() restore() 1.在自定义控件当中你onMeasure和onLayout的工作做完成以后就该绘制该控件了,有时候需要自己在控件上添加一些修饰来满足需求 ...
- asp.net 设置分页
private const int PAGESIZE = 5; //定义每页有五行数据 private void FillPageList() { int pageCount = 0; // page ...