#include
#include
#include
using namespace std;
// 10825
typedef struct INFO {
string name;
int kor;
int eng;
int math;
}info;
bool comp(info &a, info &b) {
if(a.kor != b.kor)
return a.kor > b.kor;
else {
if(a.kor == b.kor && a.eng == b.eng && a.math == b.math) {
if(a.name.compare(b.name) < 0)
return true;
return false;
}
else if(a.kor == b.kor && a.eng == b.eng) {
return a.math > b.math;
}
else {
return a.eng < b.eng;
}
}
}
int main(void) {
int N;
string name;
cin >> N;
info students[N];
for(int i = 0; i < N; i++) {
cin >> students[i].name >> students[i].kor >> students[i].eng >> students[i].math;
}
sort(students, students + N, comp);
for(int i = 0; i < N; i++) {
cout << students[i].name << endl;
}
}
백준 10825문제인데 for문도 짧고 대체 어디가 시간초과가 나는걸까요? 테스트 입력은 깔끔하게 통과합니다.
cin이랑 endl이 졸라 느려서
ios::sync_with_stdio(false); cin.tie(NULL); 써라
cin이 scanf보다 느려요? 그리고 endl도 /n보다 느린가요?
네 느려요 - dc App