#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
struct node{
int id; //8位
int v,t;
int tot;
};
bool cmp(node&a,node&b){
if(a.tot!=b.tot){
return a.tot>b.tot;
}
else if(a.v!=b.v){
return a.v>b.v;
}
else{
return a.id<b.id;
}
}
vector<node>_1,_2,_3,_4;
int main(){
int n,low,hi,tempid,tempv,tempt,num=0;
cin>>n>>low>>hi;
for(int i=0;i<n;i++){
scanf("%d %d %d",&tempid,&tempv,&tempt);
if(tempv>=low&&tempt>=low){
num++;
if(tempv>=hi&&tempt>=hi) {
int tott=tempv+tempt;
_1.push_back({tempid,tempv,tempt,tott});
}
else if(tempv>=hi&&tempt<hi){
int tott=tempv+tempt;
_2.push_back({tempid,tempv,tempt,tott});
}
else if(tempv<hi&&tempt<hi&&tempv>=tempt){
int tott=tempv+tempt;
_3.push_back({tempid,tempv,tempt,tott});
}
else {
int tott=tempv+tempt;
_4.push_back({tempid,tempv,tempt,tott});
}
}
}
printf("%d\n",num);
sort(_1.begin(),_1.end(),cmp);
for(int i=0;i<_1.size();i++){
printf("%08d %d %d\n",_1[i].id,_1[i].v,_1[i].t);
}
sort(_2.begin(),_2.end(),cmp);
for(int i=0;i<_2.size();i++){
printf("%08d %d %d\n",_2[i].id,_2[i].v,_2[i].t);
}
sort(_3.begin(),_3.end(),cmp);
for(int i=0;i<_3.size();i++){
printf("%08d %d %d\n",_3[i].id,_3[i].v,_3[i].t);
}
sort(_4.begin(),_4.end(),cmp);
for(int i=0;i<_4.size();i++){
printf("%08d %d %d\n",_4[i].id,_4[i].v,_4[i].t);
}
}
总结
1.能用复制原来编写的代码话,尽量复制,这样省时省力不易出错
2.本题就是分四个集合,集合内部自己排序,然后依次序输出即可
3.最后再稍微看一遍
英语
问题按照要处理的类型整理一下