PAT乙级1080 MOOC期终成绩 (25 分)测试点3

https://pintia.cn/problem-sets/994805260223102976/problems/994805261493977088
测试点3是指总分是59.5也算合格,,是不是很坑??
题不难 用map 很麻烦

#include 
#include 
#include 
#include 
using namespace std;
struct node{
	double G1 = -1, G2 = -1, G3 = -1, G = 0.0;
	string name;
};
bool cmp(node a, node b){
	if((int)(a.G+0.5) == (int)(b.G+0.5))	return a.name < b.name;
	else	return a.G > b.G;
}
node stu[30003];
int main(){
	map match;
	int m, n, k, sub = 1;
	cin >> m >> n >> k;
	for(int i = 1; i <= m; i++){
		cin >> stu[i].name >> stu[i].G1;
		match[stu[i].name] = sub++;
	}
	for(int i = 0; i < n; i++){
		string tmpn;
		int tmps;
		cin >> tmpn >> tmps;
		if(match[tmpn])
			stu[match[tmpn]].G2 = tmps;
		else{
			stu[sub].name = tmpn;
			stu[sub].G2 = tmps;
			match[tmpn] = sub++;
		}
	}
	for(int i = 0; i < k; i++){
		string tmpn;
		int tmps;
		cin >> tmpn >> tmps;
		if(match[tmpn])
			stu[match[tmpn]].G3 = tmps;
		else{
			stu[sub].name = tmpn;
			stu[sub].G3 = tmps;
			match[tmpn] = sub++;
		}
	}
	for(int i = 0; i < sub; i++){
		if(stu[i].G2 > stu[i].G3)
			stu[i].G = stu[i].G2*0.4 + stu[i].G3*0.6;
		else
			stu[i].G = stu[i].G3;
	} 
	sort(stu,stu+sub,cmp);
	for(int i = 0; i < sub; i++){
		if(stu[i].G1 >= 200 && stu[i].G >= 59.5)
			cout << stu[i].name << " " << stu[i].G1 << " " << stu[i].G2
			<< " " << stu[i].G3 << " " << (int)(stu[i].G+0.5) << endl; 
	}
	return 0;
}

你可能感兴趣的:(PAT乙级,PAT刷题之旅)