PAT (Advanced Level) Practice 1137 Final Grading (25 分) 凌宸1642

PAT (Advanced Level) Practice 1137 Final Grading (25 分) 凌宸1642

题目描述:

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 = ( Gmid-term × 40% + Gfinal ×60%) if Gmid-term > Gfinal , or Gfinal will be taken as the final grade G. Here Gmid-term 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.

译:参加中国大学MOOC(http://www.icourse163.org/)网络课程《数据结构》的学生,要获得证书,必须首先从网络编程中获得不少于200分 作业,然后获得不低于 60 分(满分 100 分)的最终成绩。 如果 Gmid−term > Gfinal ,则最终成绩按 G=(Gmid−term ×40%+Gfinal ×60%) 计算,否则 Gfinal 将作为期末成绩G。这里Gmid-term 和Gfinal 分别是学生期中和期末考试的成绩。

问题是不同的考试有不同的评分表。 您的工作是编写一个程序将所有评分表合并为一个。


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 Gmid−term’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).

译:每个输入文件包含一个测试用例。 对于每种情况,第一行给出三个正整数: P ,完成在线编程作业的学生人数; M,期中名单上的学生人数; 和 N,期末考试名单上的学生人数。 所有的数字都不超过10,000。

然后是三个数据块。 第一个块包含 P 个在线编程分数 Gp; 第二个包含 M 个中期得分 Gmid−term; 最后一个包含N个期末考试成绩Gfinal。 每个分数占一行,格式为:StudentID Score,其中StudentID为不超过20个英文字母和数字的字符串,Score为非负整数(在线编程最高分900,期中考试成绩和期末考试成绩满分为 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 Gmid−term Gfinal 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 qullified student.

译:对于每种情况,打印有资格获得证书的学生名单。 每个学生占一行,格式如下:

StudentID Gp Gmid-term Gfinal G

如果某个分数不存在,则输出“-1”。 输出必须按最终成绩的降序排序(G 必须四舍五入为整数)。 如果有平局,则按学生 ID 的升序输出。 保证 StudentID 都是不同的,并且至少有一个合格的学生。


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

The Idea:

  • 理解好体艺,只有满足两个要求的才能获得证书:
    • 在线编程成绩在 [200 , 900] 之间。
    • 最终成绩(非期末成绩) 在 [60 , 100] 之间 。
  • 然后按照最终成绩降序排序(如果相同则按照StudentID 升序排序)。

The Codes:

#include<bits/stdc++.h>
using namespace std ;
map<string , int> mp ;
struct Stu{
	string name ;
	int Gp = -1 , Gm = -1 , Gf = -1 , G = -1 ;
}stu[10010];
int p , m , n ;
string tname ;
int gt ;
bool cmp(Stu a , Stu b){
	if(a.G != b.G) return a.G > b.G ;
	return a.name < b.name ;
}
int main(){
	cin >> p >> m >> n ;
	for(int i = 0 ; i < p ; i ++){
		cin >> stu[i].name >> stu[i].Gp ;
		mp[stu[i].name] = i ;
	}
	for(int i = 0 ; i < m ; i ++){
		cin >> tname >> gt ;
		if(mp.count(tname)) stu[mp[tname]].Gm = gt ;
	}
	for(int i = 0 ; i < n ; i ++){
		cin >> tname >> gt ;
		if(mp.count(tname)) {
			int t = mp[tname] ;
			stu[t].Gf = gt ;
			if(stu[t].Gp >= 200){  // 只有在线编程成绩不少于200分的才会计算最终成绩 
				if(stu[t].Gm > gt) stu[t].G = (gt * 0.6 + stu[t].Gm * 0.4 + 0.5) ;
				else stu[t].G = gt ;
			}
		}
	}
	sort(stu , stu + p , cmp) ; // 最多也就参与了在线编程的所有人都合格
	for(int i = 0 ; i < p ; i ++){
		if(stu[i].G >= 60 && stu[i].G <= 100) // 最终成绩在 [60-100]之间可以获得证书 
			cout << stu[i].name << ' ' << stu[i].Gp <<  ' ' << stu[i].Gm
				<< ' ' << stu[i].Gf <<  ' ' << stu[i].G << endl ;
	}
	return 0 ;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lingchen0522

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值