λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
Algorithm πŸ§‘πŸ»‍πŸ’»/λ°±μ€€(BOJ)

[λ°±μ€€,c++] 10825번 - ꡭ영수

by dkswnkk 2021. 10. 25.
 

10825번: ꡭ영수

첫째 쀄에 λ„ν˜„μ΄λ„€ 반의 ν•™μƒμ˜ 수 N (1 ≤ N ≤ 100,000)이 주어진닀. λ‘˜μ§Έ 쀄뢀터 ν•œ 쀄에 ν•˜λ‚˜μ”© 각 ν•™μƒμ˜ 이름, κ΅­μ–΄, μ˜μ–΄, μˆ˜ν•™ μ μˆ˜κ°€ 곡백으둜 ꡬ뢄해 주어진닀. μ μˆ˜λŠ” 1보닀 ν¬κ±°λ‚˜ κ°™κ³ , 1

www.acmicpc.net

#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;

bool cmp(tuple<string, int, int, int>a, tuple<string, int, int, int>b) {
    if (get<1>(a) == get<1>(b)) {    //κ΅­μ–΄ μ μˆ˜κ°€ κ°™μ„λ•Œ
        if (get<2>(a) == get<2>(b)) {    //κ΅­μ–΄μ μˆ˜μ™€ μ˜μ–΄μ μˆ˜κ°€ κ°™μ„λ•Œ
            if (get<3>(a) == get<3>(b)) { //κ΅­μ–΄,μ˜μ–΄,μˆ˜ν•™ μ μˆ˜κ°€ κ°™μ„λ•Œ
                return get<0>(a) < get<0>(b); //사전 순으둜 좜λ ₯
            }
            return get<3>(a) > get<3>(b);    //μˆ˜ν•™μ μˆ˜κ°€ κ°μ†Œν•˜λŠ” 순으둜 좜λ ₯
        }
        return get<2>(a) < get<2>(b); //μ˜μ–΄ μ μˆ˜κ°€ μ¦κ°€ν•˜λŠ” 순으둜 좜λ ₯
    }
    else return get<1>(a) > get<1>(b);    //κ΅­μ–΄ μ μˆ˜κ°€ λ‹€λ₯Όλ•Œ κ°μ†Œν•˜λŠ” 순으둜 좜λ ₯
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<tuple<string, int, int, int>>v;
    while (N--) {
        string name;
        int kor, eng, math;
        cin >> name >> kor >> eng >> math;
        v.push_back(make_tuple(name, kor, eng, math));
    }
    sort(v.begin(), v.end(), cmp);

    for (int i = 0; i < v.size(); i++) {
        cout << get<0>(v[i]) << "\n";
    }
}

λŒ“κΈ€