PAT 1137. 期终成绩
原题链接
简单
作者:
YAX_AC
,
2024-11-14 19:49:36
,
所有人可见
,
阅读 2
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
int n,m,k,score;
string id;
struct node{
int a,b,c,avg;
string id;
}temp;
map<string,node>mp;
vector<node> ans;
bool cmp(node a,node b)
{
if(a.avg == b.avg) return a.id<b.id;
return a.avg>b.avg;
}
int main()
{
cin>>n>>m>>k;
for(int i = 0; i<n; i++)
{
cin>>id>>score;
mp[id].a = score;
mp[id].b = -1;
mp[id].c = -1;
}
for(int i = 0; i<m; i++) cin>>id>>score,mp[id].b=score;
for(int i = 0; i<k; i++) cin>>id>>score,mp[id].c=score;
for(auto t = mp.begin(); t!=mp.end(); t++)
{
if(t->second.a<200) continue;
temp.id = t->first;
temp.a = t->second.a;
temp.b = t->second.b;
temp.c = t->second.c;
if(temp.c>=temp.b) temp.avg = temp.c;
else temp.avg = (temp.b*4+temp.c*6+5)/10;
if(temp.avg >= 60) ans.push_back(temp);
}
sort(ans.begin(),ans.end(),cmp);
for(int i = 0; i<ans.size(); i++)
{
cout<<ans[i].id;
printf(" %d %d %d %d\n",ans[i].a,ans[i].b,ans[i].c,ans[i].avg);
}
return 0;
}