본문 바로가기
카테고리 없음

백준 10825 c++

by park_hama 2024. 7. 27.

vector 자료형은 참 만능인 것 같다.

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

typedef struct score {
	string name;
	int kor, eng, math;
}Score;

bool compare(Score p1, Score p2) {
	
	if (p1.kor == p2.kor && p1.eng == p2.eng && p1.math == p2.math)
		return p1.name < p2.name;
	else if (p1.kor == p2.kor && p1.eng == p2.eng)
		return p1.math > p2.math;
	else if (p1.kor == p2.kor)
		return p1.eng < p2.eng;
	else
		return p1.kor > p2.kor;
		

}

int main() {
	
	int n;
	cin >> n;

	vector<Score> p(n);

	
	
	for (int i = 0; i < n; i++) {
	
		cin >> p[i].name >> p[i].kor >> p[i].eng >> p[i].math;

	}

	sort(p.begin(), p.end(), compare);

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

}