#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct People{
int id;
int virtue;
int talent;
};
vector<People> sages;
vector<People> noblemen;
vector<People> foolmen;
vector<People> others;
bool cmp(People a,People b){
if(a.talent + a.virtue != b.talent + b.virtue)
return a.talent + a.virtue > b.talent + b.virtue;
else if(a.virtue != b.virtue)
return a.virtue > b.virtue;
else
return a.id < b.id;
}
// virtue 和 talent >= higher_line 的 -> sages
// virtue >= higher_line && talent < higher_line -> noblemen
// virtue < higher_line && talent < higher_line && virtue >= talent -> foolmen
// virtue >= lower_bound && talent >= lower_bound -> others
int main(){
int n,lower_bound,higher_line;
scanf("%d %d %d",&n,&lower_bound,&higher_line);
for(int i = 0;i < n;i++){
People temp;
scanf("%d %d %d",&temp.id,&temp.virtue,&temp.talent);
if(temp.virtue < lower_bound || temp.talent < lower_bound)
continue;
if(temp.virtue >= higher_line && temp.talent >= higher_line){
sages.push_back(temp);
}
else if(temp.virtue >= higher_line && temp.talent < higher_line){
noblemen.push_back(temp);
}
else if(temp.virtue < higher_line && temp.talent < higher_line && temp.virtue >= temp.talent){
foolmen.push_back(temp);
}
else{
others.push_back(temp);
}
}
sort(sages.begin(),sages.end(),cmp);
sort(noblemen.begin(),noblemen.end(),cmp);
sort(foolmen.begin(),foolmen.end(),cmp);
sort(others.begin(),others.end(),cmp);
int s = sages.size() + noblemen.size() + foolmen.size() + others.size();
printf("%d\n",s);
s = sages.size();
for(int i = 0;i < s;i++){
printf("%08d %d %d\n",sages[i].id,sages[i].virtue,sages[i].talent);
}
s = noblemen.size();
for(int i = 0;i < s;i++){
printf("%08d %d %d\n",noblemen[i].id,noblemen[i].virtue,noblemen[i].talent);
}
s = foolmen.size();
for(int i = 0;i < s;i++){
printf("%08d %d %d\n",foolmen[i].id,foolmen[i].virtue,foolmen[i].talent);
}
s = others.size();
for(int i = 0;i < s;i++){
printf("%08d %d %d\n",others[i].id,others[i].virtue,others[i].talent);
}
system("pause");
return 0;
}
PAT | A1062 Talent and Virtue
最新推荐文章于 2024-10-08 00:02:21 发布