백준

[백준] 10825번 국영수 (C++ , 정렬)

해랑쓰 2021. 10. 7. 23:57
728x90
반응형

 

 

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

struct Student {
	string name;
	int kor, eng, math;
};
Student s[100001];

bool comp(Student &a, Student &b) {
	if (a.kor == b.kor) {
		if (a.eng == b.eng) {
			if (a.math == b.math) {
				return a.name < b.name;
			}
			else return a.math > b.math;
			
		}
		else return a.eng < b.eng;
		
	}return a.kor > b.kor;
	

}

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i].name;
		cin >> s[i].kor;
		cin >> s[i].eng;
		cin >> s[i].math;
	}
	sort(s, s + n, comp);

	for (int i = 0; i < n; i++) {
		cout << s[i].name << "\n";
	}

	return 0;
}
728x90
반응형