题目地址
代码
#include<stdio.h>
#include<algorithm>
using namespace std;
struct student{
long long No;
int virtue;
int talent;
int sum;
int level;
int rank;
}stu[100001];
bool cmp(student a,student b){
if(a.level!=b.level){
return a.level < b.level;
}else if(a.sum!=b.sum){
return a.sum > b.sum;
}else if(a.virtue!=b.virtue){
return a.virtue>b.virtue;
}else{
return a.No<b.No;
}
}
int main(){
int N,m;
int limit;
int priority;
scanf("%d%d%d",&N,&limit,&priority);
m = N;
for(int i=0;i<N;i++){
scanf("%lld%d%d",&stu[i].No,&stu[i].virtue,&stu[i].talent);
stu[i].sum = stu[i].virtue + stu[i].talent;
if(stu[i].virtue>=limit && stu[i].talent>=limit){
if(stu[i].virtue>=priority && stu[i].talent>=priority){
stu[i].level = 1;
}else if(stu[i].virtue>=priority){
stu[i].level = 2;
}else if(stu[i].virtue>=stu[i].talent){
stu[i].level = 3;
}else{
stu[i].level = 4;
}
}else{
stu[i].level = 5;
m--;
}
}
sort(stu,stu+N,cmp);
printf("%d\n",m);
for(int i=0;i<m;i++){
printf("%lld %d %d\n",stu[i].No,stu[i].virtue,stu[i].talent);
}
return 0;
}