[p1093 - 장학금] 문제 풀이 기록
2688 단어 낙 곡 해제
총결산
코드
#include
#include
using namespace std;
const int maxn= 305;
int size;
struct Student{
int id;
int chinese;
int math;
int english;
int sum;
bool operatorconst Student& s)const{
if(this->sum != s.sum) return this->sum > s.sum;
if(this->chinese != s.chinese) return this->chinese > s.chinese;
return this->id < s.id;
}
};
Student s[maxn];
int main(){
scanf("%d", &size);
for(int i=1; i<=size; ++i){
Student &now= s[i];
now.id= i;
scanf("%d%d%d
", &now.chinese, &now.math, &now.english);
now.sum= now.chinese+now.math+now.english;
}
sort(s+1, s+1+size);
for(int i=1; i<=5; ++i){
Student &now= s[i];
printf("%d %d
", now.id, now.sum);
}
return 0;
}