PAT_A1137#Final Grading

PAT_A1137#Final Grading

Source:

PAT A1137 Final Grading (25 分)

Description:

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 0 if Gmidterm​​>Gfinal​​, or Gfinal​​ will be taken as the final grade G. Here Gmidterm​​ 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 Gmidterm​​’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​​ Gmidterm​​ Gfinal​​ G

If some score does not exist, output “−” 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

Keys:

  • 快乐模拟
  • map(C++ STL)
  • string(C++ STL)

Attention:

  • 四舍五入要用round()函数;
  • MAXSIZE最多有三倍的1E4;

Code:

 1 /*  2 Data: 2019-05-26 21:12:36  3 Problem: PAT_A1137#Final Grading  4 AC: 55:00  5  6 题目大意:  7 获得证书需要,编程任务不少于200分,总分不少于60分  8 如果期中>期末分数,则总分=期中*0.4+期末*0.6  9 反之,总分=期末分数  10 输入:  11 第一行给出,完成编程的人数P,参加期中考试的人数M,参加期末考试的人数N,均<=1e4  12 接下来给出各项分数;id不超过20位  13 */  14  15 #include<cstdio>  16 #include<string>  17 #include<camth>  18 #include<map>  19 #include<iostream>  20 #include<algorithm>  21 using namespace std;  22 const int M=1e4+10;  23 int pt=1,pass[M]={ 0};  24 struct node  25 {  26 string id;  27 int gp,gm,gf,g;  28 }info[M],ans[M];  29 map<string,int> mp;  30  31 int ToInt(string s)  32 {  33 if(mp[s]==0)  34  {  35 mp[s]=pt;  36 info[pt].id=s;  37 info[pt].gm=-1;  38 info[pt].gf=-1;  39 return pt++;  40  }  41 else  42 return mp[s];  43 }  44  45 bool cmp(node a, node b)  46 {  47 if(a.g != b.g)  48 return a.g > b.g;  49 else  50 return a.id < b.id;  51 }  52  53 int main()  54 {  55 #ifdef ONLINE_JUDGE  56 #else  57 freopen("Test.txt", "r", stdin);  58 #endif  59  60 int n,m,p,g;  61 string s;  62 scanf("%d%d%d", &n,&m,&p);  63 for(int i=0; i<n; i++)  64  {  65 cin >> s >> g;  66 int v=ToInt(s);  67 info[v].gp=g;  68 pass[v]++;  69  }  70 for(int i=0; i<m; i++)  71  {  72 cin >> s >> g;  73 int v=ToInt(s);  74 info[v].gm=g;  75 if(pass[v]) pass[v]++;  76  }  77 for(int i=0; i<p; i++)  78  {  79 cin >> s >> g;  80 int v=ToInt(s);  81 info[v].gf=g;  82 if(pass[v]) pass[v]++;  83  }  84 int cnt=0;  85 for(int i=1; i<pt; i++)  86  {  87 if(pass[i]>=2 && info[i].gp>=200)  88  {  89 if(info[i].gm > info[i].gf)  90 info[i].g = (int)round(0.4*info[i].gm+0.6*info[i].gf);  91 else  92 info[i].g = info[i].gf;  93 if(info[i].g >= 60)  94 ans[cnt++] = info[i];  95  }  96  }  97 sort(ans,ans+cnt,cmp);  98 for(int i=0; i<cnt; i++)  99  { 100 cout << ans[i].id; 101 printf(" %d %d %d %d\n", ans[i].gp,ans[i].gm,ans[i].gf,ans[i].g); 102  } 103 104 return 0; 105 }

 

转载于:https://www.cnblogs.com/blue-lin/p/10932423.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/100892.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • Centos7安装Nginx详细安装步骤

    Centos7安装Nginx详细安装步骤Centos7安装Nginx步骤手动配置nginx的yum仓库使用yum命令安装nginx启动nginx访问nginx1.指定nginx的yum仓库说明:centos系统中默认的yum仓库中没有nginx的安装包,所以要想安装nginx需要单独指定它的仓库地址1.1将nginx.repo上传到Linux服务器下的/etc/yum.repos.d/下nginx.repo文件…

  • 字符串匹配——枚举法[通俗易懂]

    字符串匹配——枚举法[通俗易懂]字符串匹配——枚举法给定主串T和模式串P,返回P在T中首次出现的位置,如果P不存在于T中,返回-1。这样的问题就是字符串匹配问题,这里先给出枚举法的思想。设主串T的长度为n,模式串P的长度为m。主串从0到n-m,每次选取连续的m个字符,跟模式串P的m个字符进行一一比较。伪代码BruteForce(T,P)01fors<-0ton-m02j<-003//check

  • InstallShield 2010打包

    InstallShield 2010打包打包安装文件。本例子在VS2010下完成,对应的InstallShield2010版的打包程序。如果已安装InstallShield2010,会在VS2010中有体现。新建项目,在已安装的模板中选

  • java性能优化技巧二

    1. 谨慎对待Java的循环遍历Java中的列表遍历可比它看起来要麻烦多了。就以下面两段代码为例:A:1234private final List _bars;for(Bar bar : _bars) {    //Do important stuff}B:12345private final List _bars;for(int i = 0; i _bars.size(); i++) {Bar

  • @RequestMapping和@GetMapping @PostMapping 区别

        最近学习看一些代码,发现对于发送请求这件事,有的地方用@RequestMapping,有的地方用@PostMapping,为了搞清楚区别,特意查了下spring源代码,现在特此记录下。 @GetMapping用于将HTTPget请求映射到特定处理程序的方法注解具体来说,@GetMapping是一个组合注解,是@RequestMapping(method=RequestM…

  • MFC 键盘钩子「建议收藏」

    MFC 键盘钩子「建议收藏」一、前言一日,看见我妈正在用电脑练习打字,频频低头看键盘,我想:要是键盘能发音的话,不就可以方便她养成”盲打”的好习惯吗?光想不做可不行,开始行动(您可千万别急着去拿工具箱啊^_^)…按键能发音,其关键就是让程序能够知道当前键盘上是哪个键被按下,并播放相应的声音,自己的程序当然不在话下,那么其它程序当前按下哪个键如何得知呢?利用键盘钩子便可以很好地解决。下载本文的全部源代码大

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号