cgy12306
[백준 BoJ] 10825 - 국영수 본문
// https://www.acmicpc.net/problem/10825
// 국영수
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef struct student{
string name;
int kor, eng, math;
}student;
bool cmp(student a, student b) {
if (a.kor == b.kor && a.eng == b.eng && a.math == b.math) return a.name < b.name;
if (a.kor == b.kor && a.eng == b.eng) return a.math > b.math;
if (a.kor == b.kor) return a.eng < b.eng;
return a.kor > b.kor;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N;
cin >> N;
vector<student> v(N);
for (int i = 0; i < N; i++) {
cin >> v[i].name >> v[i].kor >> v[i].eng >> v[i].math;
}
sort(v.begin(), v.end(), cmp);
for (auto V : v) {
cout << V.name << "\n";
}
}
'Algorithm > C++' 카테고리의 다른 글
[백준 BoJ] 11659 - 구간 합 구하기 4 (0) | 2022.01.14 |
---|---|
[백준 BoJ] 11652 - 카드 (0) | 2022.01.13 |
[백준 BoJ] 17404 - RGB거리 2 (0) | 2022.01.13 |
[백준 BoJ] 1149 - RGB의 거리 (0) | 2022.01.12 |
[백준 BoJ] 14002 - 가장 긴 증가하는 부분 수열 4 (0) | 2022.01.11 |
Comments