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

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 排名前十的时序数据库[通俗易懂]

    排名前十的时序数据库[通俗易懂]时序数据库全称为时间序列数据库。时间序列数据库主要用于指处理带时间标签(按照时间的顺序变化,即时间序列化)的数据,带时间标签的数据也称为时间序列数据。时序数据的兴起还是榜上了物联网的大风。物联网(InternetofThings,简称IOT)是指通过各种信息传感器实时采集任何需要管理设备的信息,并进行管理。物联网的基础数据具有数据量大、结构单一、时间属性强、查询简单等特点,传统的关系型数据库在面对物联网数据时,显得应对发力,基本上属于功能过剩但性能不足。目前最新的DB-Engine上时序数据库排名如下

    2022年10月4日
    3
  • c语言中fprintf_c语言输出函数printf

    c语言中fprintf_c语言输出函数printf目录一.fprintf函数简介二.fprintf函数使用三.猜你喜欢零基础C/C++学习路线推荐:C/C++学习目录>>C语言基础入门一.fprintf函数简介fprintf是C/C++中的一个格式化库函数,位于头文件中,其作用是格式化输出到一个流文件中;函数原型为/**描述:fputs函数是向指定的文件写入一个字符串**参数:*[in]stream:文件指针句柄;*[in]format:格式化字符串,

    2022年10月10日
    4
  • datagrip激活码(JetBrains全家桶)

    (datagrip激活码)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月26日
    804
  • java actioncontext_关于struts2中ActionContext的实现原理

    java actioncontext_关于struts2中ActionContext的实现原理北京,雾霾天气阻止了今天的马拉松之行,蜗居一天。为一个问题“struts2如何保证ActionContext每次取的都是本次请求所对应的实例?”,给一个网友解释了半天。首先,我们知道,struts2和struts1的一个重要区别就是它进行了Action类和Servlet的解耦。而又提供了获取ServletAPI的其它通道,就是ActionContext(别跟我说还有个ServletActionC…

    2025年10月14日
    6
  • Python爬取豆瓣电影Top250并进行数据分析

    Python爬取豆瓣电影Top250并进行数据分析Python数据分析–豆瓣电影Top250利用Python爬取豆瓣电影TOP250并进行数据分析,对于众多爬虫爱好者,应该并不陌生。很多人都会以此作为第一个练手的小项目。当然这也多亏了豆瓣的包容,没有加以太多的反爬措施,对新手比较友好。版权声明:本文为博主原创文章,创作不易本文链接:数据爬取翻页操作第一页:https://movie.douban.com/top250第二页:https://movie.douban.com/top250?start=25&filter=第三页

    2022年6月1日
    59
  • 利用Python做一个漂亮女生词云跳舞视频「建议收藏」

    利用Python做一个漂亮女生词云跳舞视频「建议收藏」利用Python做一个漂亮小姐姐词云跳舞视频。实现思路:1.下载视频2.获取弹幕内容3.从视频中提取图片4.利用百度AI进行人像分割5.小姐姐跳舞词云生成6.合成跳舞视频7.视频插入音频B站上的漂亮的小姐姐真的好多好多,利用you-get大法下载了一个B站上跳舞的小姐姐视频,利用视频中的弹幕来制作一个漂亮小姐姐词云跳舞视频,一起来看看吧。

    2022年6月20日
    37

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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