链接https://pintia.cn/problem-sets/994805342720868352/problems/994805345401028608

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 = (G~mid-term~x 40% + G~final~x 60%) if G~mid-term~ > G~final~, or G~final~ will be taken as the final grade G. Here G~mid-term~ and G~final~ 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 G~p~'s; the second one contains M mid-term scores G~mid-term~'s; and the last one contains N final exam scores G~final~'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 G~p~ G~mid-term~ G~final~ 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 qualified 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

几个概念需要理清,即final grade 和final grade G。前者是最后的总成绩,后者是期末考试的成绩。最后要求是总成绩不小于60
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cstring>
#define DEBUG(x) cout << #x << " = " << x << endl
using namespace std;
struct student{int nId;string Id;int online,middle,last,total;student(){online=-1;middle=-1;last=-1;total=-1;}void calculate(){if(middle>last)total=middle*0.4+last*0.6+0.5;else total=last;}void Print(){cout<<Id<<" ";cout<<online<<" "<<middle<<" "<<last<<" "<<total<<endl;}bool operator<(const student &s)const{if(total!=s.total)return total>s.total;else {return Id<s.Id;}}
};
int ptr=0;
map<string,int>num;
map<int,string>id;
int P,M,N;
vector<student>v;
int main()
{
//    freopen("in.txt","r",stdin);scanf("%d%d%d",&P,&M,&N);for(int i=0;i<P;i++){student st;cin>>st.Id>>st.online;if(st.online>=200) {if(num.find(st.Id)==num.end()) {num[st.Id]=ptr;id[ptr]=st.Id;st.nId=ptr;v.push_back(st);ptr++;} else {int i=num[st.Id];v[i].online=max(v[i].online,st.online);}}}for(int i=0;i<M;i++){string s;int m;cin>>s>>m;if(num.find(s)!=num.end()){int id=num[s];v[id].middle=max(v[id].middle,m);}}for(int i=0;i<N;i++){string s;int m;cin>>s>>m;if(num.find(s)!=num.end()){int id=num[s];v[id].last=max(v[id].last,m);v[id].calculate();}}sort(v.begin(),v.end());for(int i=0;i<v.size();i++){if(v[i].total>=60)v[i].Print();}return 0;
}

 

转载于:https://www.cnblogs.com/MalcolmMeng/p/9187106.html

PAT1137 Final Grading相关推荐

  1. PAT甲级1137 Final Grading:[C++题解]结构体、排序、哈希表、结构体构造函数、结构体内写函数

    文章目录 题目分析 题目链接 题目分析 分析: 首先一个学生有id,另外有4个成绩:编程成绩.期中成绩.期末成绩.总评成绩.现有3个成绩单:编程成绩.期中成绩.期末成绩,让计算总评成绩,并排序输出. ...

  2. 1137 Final Grading (PAT 甲级)

    写完后又参考其他人的写法修改了一下:发现既然只有取得final exam成绩的学生才有最终成绩,那在42行到54行代码中,完全可以把最终成绩算出来(没有进行final exam的学生无最终成绩,不进入 ...

  3. PAT甲级1141 PAT Ranking of Institutions :[C++题解]结构体、排序、哈希表、结构体构造函数、结构体内写函数、排名

    文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:和下面这题是一道题: PAT甲级1137 Final Grading:[C++题解]结构体.排序.哈希表.结构体构造函数.结构体内写函 ...

  4. PAT甲级题目翻译+答案 AcWing(哈希表)

    1048 Find Coins (25 分) 题意 : 给一序列,要求从中选出两个值使得它们的和恰好等于m,输出第一个值字典序最小且升序的方案 思路 : 看似O(n2)O(n^2)O(n2),其实可以 ...

  5. 【PAT甲级真题整理五】1121~1155

    终于考完了qaq把最后一堆也整理出来了 目录 1121 Damn Single(25)set.map的使用 1122 Hamiltonian Cycle(25)哈密顿回路 1123 Is It a C ...

  6. 2020年9月PAT甲级满分必备刷题技巧

    2020年7月的考试结束了,除了本次的考题更新,短期内不会更新. [7月题目的特点:首次线上考试,没出链表.树相关的模板题,第2到4题背景新颖,大大降低了抄袭历年代码的可能性,可以看作是线上考试的新趋 ...

  7. 【PAT甲级】A1101-A1155刷题记录

    文章目录 (递推) A1101 Quick Sort (25 分) 0.23 (静态二叉树+遍历) A1102 Invert a Binary Tree (25 分) 0.51 (数学问题) A110 ...

  8. 刷PAT甲级的各题思路、细节以及遇到的问题记录

    1001 A+B Format (20分) 因为一定会用到字符串,而string非常好用,但是用的时候一定要注意不能越界访问,否则会在运行时出现abort() has been called. 100 ...

  9. unity黑白滤镜_unity颜色分级图像滤镜着色器Fast Mobile Color Grading 1.0

    unity颜色分级图像滤镜着色器Fast Mobile Color Grading 1.0,包含7个着色器,可用于手机游戏或桌面游戏.大多数着色器都经过优化,可在移动设备上平滑运行,同时保持图像良好的 ...

  10. 题目1002:Grading

    题目描述: Grading hundreds of thousands of Graduate Entrance Exams is a hard work. It is even harder to ...

最新文章

  1. 2022-2028年中国特高压电网行业深度调研及投资前景预测报告
  2. O(N)的时间复杂度找出a[N]中那个重复的数字
  3. [ZJOI2007]棋盘制作 悬线法dp 求限制下的最大子矩阵
  4. UVa 10026 - Shoemaker's Problem
  5. mimakatz用法_两步完成利用procdump64+mimikatz获取win用户密码
  6. 出现问题Debug Assertion Failed!
  7. mysql基础之存储引擎
  8. 郑大远程计算机应用基础第09,郑大远程教育《计算机应用基础》第09章在线测试...
  9. java面试简历精通n_对标金九银十:各大厂最新Java面试真题整理+简历模板
  10. 小红书数据分析工具丨借助数据教你分分钟锁定优质达人
  11. bzoj4238 电压
  12. 5G技术能不能支持在高铁列车上的多路虚拟现实业务?
  13. 扫雷用递归实现拓展空白详解
  14. 淘宝WAP版小BUG分析
  15. 为什么要对数据进行归一化处理
  16. 社交舞 - 简介,释名,风格,舞步 - 金山词霸汉语 - HAPPY Life
  17. MySQL8.0.20安装配置+用Navicat连接详细教程(win10,Navicat15)
  18. 团购网到底该如何实现平台化转型
  19. 基于RK3399Pro的TM1650键盘读取-IIC总线
  20. 中间件_Redis_02_Redis的数据类型

热门文章

  1. flutter实战1:完成一个有侧边栏的主界面
  2. Hyperledger Fabric MSP Identity Validity Rules——MSP身份验证规则
  3. Ionic 学习笔记
  4. centos6使用bacula备份系统
  5. jQuery创建Dom元素
  6. PHP设计模式——组合器模式
  7. [shell]shell 中| || () {} 用法以及shell的逻辑与或非
  8. python多进程共享变量,附共享图像内存实例
  9. Android 使用 TableLayout 布局拉伸宽度
  10. Linux,begin