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 ...
随机推荐
- oracle 统计/分析函数
Oracle从8.1.6开始提供分析函数,分析函数用于计算基于组的某种聚合值,它和聚合函数的不同之处是对于每个组返回多行,而聚合函数对于每个组只返回一行. 语法: Sql代码 <analytic ...
- 【175】Easy CHM的使用
首先下载软件,EasyCHM3.84完美破解版.rar! 安装好之后,打开程序,点击“新建”,然后浏览到存放 htm 文件的目录. 鼠标右键,选择“添加目录项”!如下图所示. 在弹出的文本框中,首先选 ...
- 基于PHP自带的mail函数实现发送邮件以及带有附件的邮件功能
PHPmail函数简介 bool mail ( string $to , string $subject , string $message [, string $additional_headers ...
- samba - linux客户端访问samba服务器的指令(转载)
转自:http://linux.sheup.com/linux/linux5303.htm linux客户端访问samba服务器的指令2004-04-23 15:18 pm来自:Linux文档现载:W ...
- 设计模式 | 组合模式(composite)
定义: 将对象组合成树形结构以表示“部分-整体”的层次结构.组合模式使得用户对单个对象和组合对象的使用具有一致性. 结构:(书中图,侵删) 一个Component接口:定义统一的方法 若干树枝(Com ...
- php 文件上传限制修改
修改PHP上传文件大小限制的方法 1. 一般的文件上传,除非文件很小.就像一个5M的文件,很可能要超过一分钟才能上传完.但在php中,默认的该页最久执行时间为 30 秒.就是说超过30秒,该脚本就停止 ...
- C#学习-EF在三层中使用
1.搭建普通三层 DAL层,BLL层,Model层,Web层: DAL层引用Model层 BLL层引用DAL层和Model层 Web层引用BLL层和Model层 2.实现EF三层的搭建(添加引用,修改 ...
- RabbitMQ指南之五:主题交换器(Topic Exchange)
在上一章中,我们完善了我们的日志系统,用direct交换器替换了fanout交换器,使得我们可以有选择性地接收消息.尽管如此,仍然还有限制:不能基于多个标准进行路由.在我们的日志系统中,我们可能不仅希 ...
- LN : leetcode 231 Power of Two
lc 231 Power of Two 231 Power of Two Given an integer, write a function to determine if it is a powe ...
- 解决Unicode编码(璘)
随着互联网发展,B/S越来越受欢迎 Code编码格式也越来载多, 在大千花花世界 中文在Web显示看似一样但实际编码并不样,导致从页面获取的资料录入到数据库中时 存取的就是Code编码 如:Unico ...