https://www.acmicpc.net/problem/10825
#10825: 국영수
첫 번째 행은 도현의 반 학생 수 N(1 ≤ N ≤ 100,000)입니다.
두 번째 줄부터 각 학생의 이름, 한글, 영어, 수학 성적이 공백으로 구분되어 순서대로 나열됩니다.
점수가 1과 1보다 크거나 같음
www.acmicpc.net
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
struct stu {
string name;
int kor, eng, math;
}; typedef struct stu STU;
int N;
STU* students;
bool compare(STU a, STU b) {
if (a.kor == b.kor && a.eng == b.eng && a.math == b.math) return a.name < b.name;
else if (a.kor == b.kor && a.eng == b.eng) return a.math > b.math;
else if (a.kor == b.kor) return a.eng < b.eng;
else return a.kor > b.kor;
}
void input() {
scanf("%d", &N);
students = new STU(N);
for (int i = 0; i < N; i++) {
string tmp;
int a, b, c;
cin >> tmp;
scanf("%d %d %d", &a, &b, &c);
students(i).name = tmp;
students(i).kor = a;
students(i).eng = b;
students(i).math = c;
}
}
void solution() {
sort(students, students + N, compare);
for (int i = 0; i < N; i++) cout << students(i).name << "\n";
}
int main() {
input();
solution();
}