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 ...
随机推荐
- JeePlus:目录
ylbtech-JeePlus:目录 1.返回顶部 0. http://www.jeeplus.org/ 0.2.文档 http://wiki.jeeplus.org/docs/show/75 0.3 ...
- Spark 二项逻辑回归__二分类
package Spark_MLlib import org.apache.spark.ml.Pipeline import org.apache.spark.ml.classification.{B ...
- J201700526-hm
プレーンテキスト 纯文本 きも 肝 リレーショナル 亲属的,相关的,有关的; ギャップ 缺口; 间隔; 分歧;
- [Swift通天遁地]二、表格表单-(1)创建自定义的UITableViewCell(单元格类)
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- 商品期货高频交易策略Tick框架
原帖地址:https://www.fmz.com/bbs-topic/1184在商品期货高频交易策略中, Tick行情的接收速度对策略的盈利结果有着决定性的影响,但市面上大多数交易框架,都是采用回调模 ...
- php+ajax+jquery实现jsonp跨域
我们有这么个html文件test.html: 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...
- redis 缓存应用
第1章 部署与安装 wget http://download.redis.io/releases/redis-3.2.10.tar.gz tar xf redis-3.2.10.tar.gz cd r ...
- POJ 2194 2850 计算几何
题意: 给你了n个圆,让你摞起来,问顶层圆心的坐标 (数据保证间隔两层的圆不会挨着) 思路: 按照题意模拟. 假设我们已经知道了一层两个相邻圆的坐标a:(x1,y1)和b:(x2,y2) 很容易求出来 ...
- 51nod 1029 大数除法
1029 大数除法 基准时间限制:4 秒 空间限制:131072 KB 分值: 160 难度:6级算法题 收藏 关注 给出2个大整数A,B,计算A / B和A Mod B的结果. Input 第1 ...
- LN : leetcode 207 Course Schedule
lc 207 Course Schedule 207 Course Schedule There are a total of n courses you have to take, labeled ...