1080 MOOC期终成绩

最后一个测试点(6分)

如果有的成绩不存在(例如某人没参加期中考试),则在相应的位置输出“−1”

如果有的成绩为0,则相应的位置应该输出的是“0”,注意不要也输出成“-1”了

额外输入样例:

2 2 2
aaa 0
bbb 200
aaa 0
bbb 0
aaa 0
bbb 60

正确的输出样例:

bbb 200 0 60 60 

如果最后一个测试点未通过,上述额外输入样例你的输出样例很可能为: 

bbb 200 -1 60 60

#include<bits/stdc++.h>
using namespace std;
struct Stu{
	string name;
	int Gp,Gm,Gf,G;
};
int p,m,n;
bool compare(const Stu &a,const Stu &b){
	if(a.G!=b.G)
		return a.G>b.G;
	else
		return a.name<b.name;
}
int main(){
	cin>>p>>m>>n;
	map<string,double> mapGp,mapGm,mapGf,mapG;
	set<string> s;
	string id;
	double score;	
	for(int i=0;i<p;i++){
		cin>>id>>score;
		mapGp[id]=score;
		mapGm[id]=-1;
		mapGf[id]=-1;
		s.insert(id);
	}
	for(int i=0;i<m;i++){
		cin>>id>>score;
		mapGm[id]=score;
		s.insert(id);
	}
	for(int i=0;i<n;i++){
		cin>>id>>score;
		mapGf[id]=score;
		s.insert(id);
	}	
	Stu stu[s.size()];
	int cnt = 0;
	for(auto it = s.begin();it!=s.end();it++){
		stu[cnt++].name = *it;
	}
	for(int i=0;i<s.size();i++){
		stu[i].Gp = mapGp[stu[i].name]==-1?-1:(mapGp[stu[i].name]);
		stu[i].Gm = mapGm[stu[i].name]==-1?-1:(mapGm[stu[i].name]);
		stu[i].G = stu[i].Gf = mapGf[stu[i].name]==0?-1:(mapGf[stu[i].name]);
		if(stu[i].Gm > stu[i].Gf){
			stu[i].G = int(stu[i].Gm*0.4 + stu[i].Gf*0.6 + 0.5);
		}
	}	
	sort(stu,stu+s.size(),compare);
	for(int i=0;i<s.size();i++){
		if(stu[i].Gp>=200&&stu[i].G>=60){
			printf("%s %d %d %d %d\n",stu[i].name.c_str(),stu[i].Gp,stu[i].Gm,stu[i].Gf,stu[i].G);
		}
	}	
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值