AcWing 1548. 才华与德行
原题链接
简单
作者:
leo123456
,
2020-08-30 17:04:56
,
所有人可见
,
阅读 505
//简单粗暴,要你变好
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
const int N=100010;
int n,pl,gl;
struct People
{
string id;
int vg,tg;
};
bool cmp(People a,People b)
{
if(a.vg+a.tg!=b.vg+b.tg) return a.vg+a.tg>b.vg+b.tg;
else if(a.vg!=b.vg) return a.vg>b.vg;
else return a.id<b.id;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>pl>>gl;
vector<People> sage;
vector<People> nobleman;
vector<People> foolman;
vector<People> others;
for(int i=0;i<n;i++)
{
string id;
int vg,tg;
cin>>id>>vg>>tg;
if(vg<pl||tg<pl) continue;
else
{
if(vg>=gl&&tg>=gl) sage.push_back({id,vg,tg});
else if(vg>=gl&&tg<gl) nobleman.push_back({id,vg,tg});
else if(vg>=tg) foolman.push_back({id,vg,tg});
else others.push_back({id,vg,tg});
}
}
cout<<sage.size()+nobleman.size()+foolman.size()+others.size()<<endl;
sort(sage.begin(),sage.end(),cmp);
for(int i=0;i<sage.size();i++)
cout<<sage[i].id<<' '<<sage[i].vg<<' '<<sage[i].tg<<endl;
sort(nobleman.begin(),nobleman.end(),cmp);
for(int i=0;i<nobleman.size();i++)
cout<<nobleman[i].id<<' '<<nobleman[i].vg<<' '<<nobleman[i].tg<<endl;
sort(foolman.begin(),foolman.end(),cmp);
for(int i=0;i<foolman.size();i++)
cout<<foolman[i].id<<' '<<foolman[i].vg<<' '<<foolman[i].tg<<endl;
sort(others.begin(),others.end(),cmp);
for(int i=0;i<others.size();i++)
cout<<others[i].id<<' '<<others[i].vg<<' '<<others[i].tg<<endl;
return 0;
}