博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT_A1137#Final Grading
阅读量:6882 次
发布时间:2019-06-27

本文共 3966 字,大约阅读时间需要 13 分钟。

Source:

Description:

For a student taking the online course "Data Structures" on China University MOOC (), 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 701234 880a1903 199ydjh2 200wehu8 300dx86w 220missing 400ydhfu77 99wehu8 55ydjh2 98dx86w 88a1903 8601234 39ydhfu77 88a1903 6601234 58wehu8 84ydjh2 82missing 99dx86w 81

Sample Output:

missing 400 -1 99 99ydjh2 200 98 82 88dx86w 220 88 81 84wehu8 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
16 #include
17 #include
18 #include
19 #include
20 #include
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
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
> s >> g; 66 int v=ToInt(s); 67 info[v].gp=g; 68 pass[v]++; 69 } 70 for(int i=0; i
> 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
> 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
=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

 

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

你可能感兴趣的文章
HttpClient使用具体解释
查看>>
导师制
查看>>
js面向对象
查看>>
EasyUI学习之menu and button(菜单和按钮)
查看>>
微信开放平台 公众号第三方平台开发 教程一 平台介绍
查看>>
javascript有关this的那些事(某渣提出的问题)
查看>>
Java构造和解析Json数据的两种方法详解二——org.json
查看>>
using log4net on my project within a self-hosted WCF application z
查看>>
[唐诗]江亭夜月送别二首(其二)-王勃
查看>>
【转】android 4.3 BLE onCharacteristicWrite没有回调
查看>>
tar命令的详解
查看>>
1.3 函数调用反汇编解析以及调用惯例案例分析
查看>>
谈谈JAVA工程狮面试中经常遇到的面试题目------什么是MVC设计模式
查看>>
【转】Android Service完全解析,关于服务你所需知道的一切(下) ---- 不错
查看>>
[STL][C++]LIST
查看>>
SQL2005:使用varchar(max)代替text
查看>>
[Git] Git 常用技巧
查看>>
单向链表的逆序操作
查看>>
kNN(K-Nearest Neighbor)最近的分类规则
查看>>
试玩GitHub
查看>>