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 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 "−" 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;
  • 从总分计算公式可以看出来,不参加期末考试,最多拿40分,是不会得到证书的

Code:

 /*
Data: 2019-08-07 20:05:38
Problem: PAT_A1137#Final Grading
AC: 32:45 题目大意:
获得证书需要,编程任务不少于200分,总分不少于60分
如果期中>期末分数,则总分=期中*0.4+期末*0.6
反之,总分=期末分数
输入:
第一行给出,完成编程的人数P,参加期中考试的人数M,参加期末考试的人数N,均<=1e4
接下来给出各项分数;id不超过20位
*/
#include<cstdio>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
const int M=1e4+;
int pt=;
struct node
{
string id;
int gp,gm,gf,g;
}info[M],temp;
map<string,int> mp;
vector<node> ans; int Hash(string s)
{
if(mp[s]==)
mp[s]=pt++;
return mp[s];
} bool cmp(const node &a, const node &b)
{
if(a.g != b.g)
return a.g > b.g;
else
return a.id < b.id;
} int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("Test.txt", "r", stdin);
#endif // ONLINE_JUDGE int n,m,p;
scanf("%d%d%d", &p,&m,&n);
for(int i=; i<p; i++)
{
temp = node{"",-,-,-,-};
cin >> temp.id >> temp.gp;
if(temp.gp<)
continue;
int pos = Hash(temp.id);
info[pos]=temp;
}
for(int i=; i<m; i++)
{
cin >> temp.id >> temp.gm;
if(mp[temp.id]==)
continue;
int pos = mp[temp.id];
info[pos].gm = temp.gm;
}
for(int i=; i<n; i++)
{
cin >> temp.id >> temp.gf;
if(mp[temp.id]==)
continue;
int pos = mp[temp.id];
info[pos].gf = temp.gf;
if(info[pos].gf >= info[pos].gm)
info[pos].g = info[pos].gf;
else
info[pos].g = (int)round((0.4)*info[pos].gm+(0.6)*info[pos].gf);
if(info[pos].g >= )
ans.push_back(info[pos]);
}
sort(ans.begin(),ans.end(),cmp);
for(int i=; i<ans.size(); i++)
printf("%s %d %d %d %d\n", ans[i].id.c_str(),ans[i].gp,ans[i].gm,ans[i].gf,ans[i].g); return ;
}

/*Data: 2019-08-07 20:05:38Problem: PAT_A1137#Final GradingAC: 32:45
题目大意:获得证书需要,编程任务不少于200分,总分不少于60分如果期中>期末分数,则总分=期中*0.4+期末*0.6反之,总分=期末分数输入:第一行给出,完成编程的人数P,参加期中考试的人数M,参加期末考试的人数N,均<=1e4接下来给出各项分数;id不超过20位*/#include<cstdio>#include<string>#include<map>#include<cmath>#include<vector>#include<iostream>#include<algorithm>using namespace std;const int M=1e4+10;int pt=1;struct node{    string id;    int gp,gm,gf,g;}info[M],temp;map<string,int> mp;vector<node> ans;
int Hash(string s){    if(mp[s]==0)        mp[s]=pt++;    return mp[s];}
bool cmp(const node &a, const node &b){    if(a.g != b.g)        return a.g > b.g;    else        return a.id < b.id;}
int main(){#ifdef ONLINE_JUDGE#else    freopen("Test.txt", "r", stdin);#endif // ONLINE_JUDGE
    int n,m,p;    scanf("%d%d%d", &p,&m,&n);    for(int i=0; i<p; i++)    {        temp = node{"",-1,-1,-1,-1};        cin >> temp.id >> temp.gp;        if(temp.gp<200)            continue;        int pos = Hash(temp.id);        info[pos]=temp;    }    for(int i=0; i<m; i++)    {        cin >> temp.id >> temp.gm;        if(mp[temp.id]==0)            continue;        int pos = mp[temp.id];        info[pos].gm = temp.gm;    }    for(int i=0; i<n; i++)    {        cin >> temp.id >> temp.gf;        if(mp[temp.id]==0)            continue;        int pos = mp[temp.id];        info[pos].gf = temp.gf;        if(info[pos].gf >= info[pos].gm)            info[pos].g = info[pos].gf;        else            info[pos].g = (int)round((0.4)*info[pos].gm+(0.6)*info[pos].gf);        if(info[pos].g >= 60)            ans.push_back(info[pos]);    }    sort(ans.begin(),ans.end(),cmp);    for(int i=0; i<ans.size(); i++)        printf("%s %d %d %d %d\n", ans[i].id.c_str(),ans[i].gp,ans[i].gm,ans[i].gf,ans[i].g);
    return 0;}

PAT_A1137#Final Grading的更多相关文章

  1. PAT 1137 Final Grading[一般][排序]

    1137 Final Grading(25 分) For a student taking the online course "Data Structures" on China ...

  2. A1137. Final Grading

    For a student taking the online course "Data Structures" on China University MOOC (http:// ...

  3. PAT A1137 Final Grading (25 分)——排序

    For a student taking the online course "Data Structures" on China University MOOC (http:// ...

  4. PAT 甲级 1137 Final Grading

    https://pintia.cn/problem-sets/994805342720868352/problems/994805345401028608 For a student taking t ...

  5. 1137 Final Grading (25 分)

    For a student taking the online course "Data Structures" on China University MOOC (http:// ...

  6. PAT 1137 Final Grading

    For a student taking the online course "Data Structures" on China University MOOC (http:// ...

  7. PAT甲级——A1137 Final Grading【25】

    For a student taking the online course "Data Structures" on China University MOOC (http:// ...

  8. 1137 Final Grading

    题意:排序题. 思路:通过unordered_map来存储考生姓名与其成绩信息结构体的映射,成绩初始化为-1,在读入数据时更新各个成绩,最后计算最终成绩并把符合条件的学生存入vector,再排序即可. ...

  9. PAT甲级目录

    树(23) 备注 1004 Counting Leaves   1020 Tree Traversals   1043 Is It a Binary Search Tree 判断BST,BST的性质 ...

随机推荐

  1. [bzoj4282]慎二的随机数列_动态规划_贪心

    慎二的随机数列 bzoj-4282 题目大意:一个序列,序列上有一些数是给定的,而有一些位置上的数可以任意选择.问最长上升子序列. 注释:$1\le n\le 10^5$. 想法:结论:逢N必选.N是 ...

  2. springcloud(十一):服务网关Zuul高级篇

    时间过的很快,写springcloud(十):服务网关zuul初级篇还在半年前,现在已经是2018年了,我们继续探讨Zuul更高级的使用方式. 上篇文章主要介绍了Zuul网关使用模式,以及自动转发机制 ...

  3. solaris11-text-安装GUI(gnome)

      http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=45057&id=3018467 1.下载所需的资源Text Ins ...

  4. 2014腾讯实习生笔试题——define与typedef

    2014腾讯实习生笔试(广州站)第26题填空题: #define MAX_NUM 1000+1 int Temp = Max_NUM*10; 则Temp的值为( ) 答案是:1010, 由于宏定义仅仅 ...

  5. Android 实现文字与图片的混排

    在我们的项目中,常常会碰到图片与文字混排的问题.解决这类问题的方法有非常多,本文给出的方法不是唯一的.仅仅有依据实际场景才干找到更适合的方法. 本文主要通过xml布局来实现图片与文字的混排(水平排列) ...

  6. hibernate4中oracle,sqlserver,mysql数据库的sql方言配置(SQL Dialects)

    hibernate4中oracle,mysql,sqlserver数据库的sql方言配置(SQL Dialects) 数据库类型 Hibernate sql方言 DB2 org.hibernate.d ...

  7. luogu1265 公路修建

    题目描述 某国有n个城市,它们互相之间没有公路相通,因此交通十分不便.为解决这一“行路难”的问题,政府决定修建公路.修建公路的任务由各城市共同完成. 修建工程分若干轮完成.在每一轮中,每个城市选择一个 ...

  8. 【辨异】—— 可见 vs. 不可见

    1. 常见对比 物理可见,逻辑不可见: 效果可见: 对于一个文档,字符.图形可见,行.列.页呀等结构化的元素,不可见,它们各是一种逻辑组织与安排: 观念(思维方式,看待事情的方式)是不可见的,但行为是 ...

  9. SQL 导出表数据存储过程

    SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- ...

  10. 基于Spark ML的Titanic Challenge (Top 6%)

    下面代码按照之前参加Kaggle的python代码改写,只完成了模型的训练过程,还需要对test集的数据进行转换和对test集进行预测. scala 2.11.12 spark 2.2.2 packa ...