patA 1062. Talent and Virtue

#include <iostream>
#include <cstdio> 
#include <algorithm>
#include <cstring>
using namespace std;
struct person{
char id[15];
int v_score;
int g_score;
int rank;
bool in;
person(){
in=true;
}
bool operator <(const person &p) const {
if(rank!=p.rank) return rank<p.rank;
else if(v_score+g_score !=p.v_score+p.g_score) return v_score+g_score > p.v_score+p.g_score;
else if(v_score!=p.v_score) return v_score > p.v_score;
else return strcmp(id,p.id)<0;

}stu[100001];
int main(int argc, char** argv) {
int N;
scanf("%d",&N);
int L,H;
scanf("%d%d",&L,&H);
for(int i=0;i<N;i++){
scanf("%s %d %d",stu[i].id,&stu[i].v_score,&stu[i].g_score);
if(stu[i].v_score<L || stu[i].g_score<L) stu[i].in=false;
else if(stu[i].v_score>=H && stu[i].g_score>=H) stu[i].rank=1;
else if(stu[i].v_score>=H && stu[i].g_score<H) stu[i].rank=2;
else if(stu[i].v_score<H && stu[i].g_score<H && stu[i].v_score>=stu[i].g_score) stu[i].rank=3;
else stu[i].rank=4;
}
sort(stu,stu+N);
int count=0;
for(int i=0;i<N;i++){
if(stu[i].in==true) count++;
}
printf("%d\n",count);
for(int i=0;i<N;i++){
if(stu[i].in==true) {
printf("%s %d %d\n",stu[i].id,stu[i].v_score,stu[i].g_score);
}
}
return 0;

}

patA 1062. Talent and Virtue