Algorithm πŸ§‘πŸ»‍πŸ’»/λ°±μ€€(BOJ)

[λ°±μ€€,c++] 11557번 - Yangjojang of The Year

dkswnkk 2021. 10. 28. 20:14
 

11557번: Yangjojang of The Year

μž…ν•™ OTλ•Œ λˆ„κ΅¬λ³΄λ‹€λ„ 남닀λ₯΄κ²Œ λ†€μ•˜λ˜ 당신은 μžμ—°μŠ€λŸ½κ²Œ 1ν•™λ…„ κ³ΌλŒ€λ₯Ό μ—­μž„ν•˜κ²Œ λ˜μ—ˆλ‹€. νƒ€κ΅μ™€μ˜ 쑰인트 μ— ν‹°λ₯Ό κΈ°νšν•˜λ €λŠ” 당신은 κ·Όμ²˜μ— μžˆλŠ” 학ꡐ 쀑 μ–΄λŠ 학ꡐ가 μˆ μ„ κ°€μž₯ 많이 λ¨ΉλŠ”μ§€

www.acmicpc.net

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int T; cin >> T;

    while (T--) {
        int N; cin >> N;
        vector<pair<int, string>> v;
        for (int i = 0; i < N; i++) {
            string S; int L; cin >> S >> L;
            v.push_back({ L,S });
        }
        sort(v.begin(), v.end(), greater<>());
        cout << v.front().second<<"\n";
    }
}