AcWing 1630. 期终成绩
原题链接
简单
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<cmath>
using namespace std;
const int N=10004;
int p,m,n;
struct node
{
string name;
int cod=-1,mid=-1,fin=-1,all=0;
};
unordered_map<string,node> map;
vector<node> res;
void make(node &a)
{
if(a.mid>=a.fin) a.all=round(a.mid*0.4+a.fin*0.6);
else a.all=a.fin;
}
bool cmp(node a,node b)
{
if(a.all!=b.all)
return a.all>b.all;
return a.name<b.name;
}
int main()
{
cin>>p>>n>>m;
for(int i=0;i<p;i++)
{
string a;
int b;
cin>>a>>b;
map[a].name=a;
map[a].cod=b;
}
for(int i=0;i<n;i++)
{
string a;
int b;
cin>>a>>b;map[a].name=a;
map[a].mid=b;
}
for(int i=0;i<m;i++)
{
string a;
int b;
cin>>a>>b;map[a].name=a;
map[a].fin=b;
}
// vector<node> res;
for(auto i:map)
{
if(i.second.cod<200) continue;
make(i.second);
if(i.second.all>=60)
res.push_back(i.second );
}
sort(res.begin(),res.end(),cmp);
for(auto i:res)
cout<<i.name<<' '<<i.cod<<' '<<i.mid<<' '<<i.fin<<' '<<i.all<<endl;
return 0;
}