PAT 1137 Final Grading
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<map>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
struct node{
string name;
int Gp, Gm, Gf, G;
};
bool cmp(node n1, node n2){
return (n1.G==n2.G?n1.name<n2.name:n1.G>n2.G);
}
int main(){
map<string, int> index;
vector<node> rank;
string id;
int p, m, n, cnt=1, s;
cin>>p>>m>>n;
for(int i=0; i<p; i++){
cin>>id>>s;
if(s>=200){
rank.push_back(node{id, s, -1, -1});
index[id]=cnt++;
}
}
for(int i=0; i<m; i++){
cin>>id>>s;
if(index[id]!=0)
rank[index[id]-1].Gm=s;
}
for(int i=0; i<n; i++){
cin>>id>>s;
if(index[id]!=0){
rank[index[id]-1].Gf=s;
if(s>=rank[index[id]-1].Gm)
rank[index[id]-1].G=s;
else
rank[index[id]-1].G=round(0.4*rank[index[id]-1].Gm+0.6*s);
}
}
sort(rank.begin(), rank.end(), cmp);
for(int i=0; i<rank.size(); i++)
if(rank[i].G>=60)
cout<<rank[i].name<<" "<<rank[i].Gp<<" "<<rank[i].Gm<<" "<<rank[i].Gf<<" "<<rank[i].G<<endl;
return 0;
}
PAT 1137 Final Grading的更多相关文章
- 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 A1137 Final Grading (25 分)——排序
For a student taking the online course "Data Structures" on China University MOOC (http:// ...
- 1137 Final Grading (25 分)
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甲级——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 (Advanced Level) 1136~1139:1136模拟 1137模拟 1138 前序中序求后序 1139模拟
1136 A Delayed Palindrome(20 分) 题意:给定字符串A,判断A是否是回文串.若不是,则将A反转得到B,A和B相加得C,若C是回文串,则A被称为a delayed palin ...
随机推荐
- JavaScript 解析读取XML文档 实例代码(转)
JavaScript解析读取XML文件,主要就是加载并解析XML文件,然后就可以测试解析的XML文件的内容,打印输出来. 在线演示:http://demo.jb51.net/js/2012/readx ...
- sql数据库如何在数据库里面把其中一个数据库的表复制到另一个数据库里面
在sqlserver数据库里面,我们肯定有这样一个情况,假如我用的是SQL2008,如何把数据库里面的整个表以及表内数据复制到另外一个表中.那应该如何操作??有两种方法,我们一起来看一下 复制表结构: ...
- Android之条形码、二维码扫描框架(非原创)
文章大纲 一.条形码.二维码扫描框架介绍二.条形码.二维码的区别和组成结构介绍三.条形码.二维码扫描框架应用场景四.BGAQRCode-Android框架实战五.项目源码下载六.参考文章 一.条形码. ...
- 为什么前后端分离不利于seo
搜索引擎的基础爬虫的原理就是抓取你的url,然后获取你的html源代码并解析. 而你的页面通常用了vue等js的数据绑定机制来展示页面数据,爬虫获取到的html是你的模型页面而不是最终数据的渲染页面, ...
- linux vi 块操作、多窗口
vim 块选择v:字符选择或者行选择[ctrl]+v: 块选择y:将反白的地方复制d:将反白的地方删除 多窗口:sp {filename} 打开一个新的窗口[ctrl]+w+j或者[ctrl]+w+向 ...
- 贪心/思维题 UVA 11292 The Dragon of Loowater
题目传送门 /* 题意:n个头,m个士兵,问能否砍掉n个头 贪心/思维题:两个数组升序排序,用最弱的士兵砍掉当前的头 */ #include <cstdio> #include <c ...
- struct结构的一些内容
srtuct结构的定义: 访问修饰符 struct 结构名{ //方法体 } 结构定义的特点: 1.结构中可以有字段(属性),也可以有方法 2.定义时,结构的字段不能被赋初值 3.结构和类一样都有默 ...
- VC++常见错误原因解析--error LNK2019: 无法解析的外部符号 "public: void __thiscall
根据个人遇到这个错误时的记录,原因可以分为一下几种: 原因一: 只是在.h里面声明了某个方法, 没有在cpp里面实现 . 具体讲,有时候在头文件中声明了需要的方法,确实忘记了在源文件中实现: 有时候在 ...
- 判断IE浏览器的类型以及提示信息(低版本浏览器不予显示)
//浏览器IE版本判断(function(window) { var theUA = window.navigator.userAgent.toLowerCase(); if ((theU ...
- php angular/think angular/php模版引擎
在thinphp5中发现一个好用的模版引擎—think-angular, 此模板引擎主要特点是 不需要额外的标签定义, 全部使用属性定义, 写好的模板文件在IDE格式化代码的时候很整洁, 因为套完的模 ...