4과목 점수를 입력받고 점수합 내림차순, id 오름차순으로 정렬한 다음 id==1인 사람이 몇등인지 출력하는 문제다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
typedef long long ll;
 
int n;
vector<pair<intint>> v;
 
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a += b + c + d;
        v.push_back({ -a,i });
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; ++i) {
        if (v[i].second == 0) {
            cout << i + 1;
            break;
        }
    }
    return 0;
}
cs


'codeforces > #502 div1+div2' 카테고리의 다른 글

D. The Wu  (0) 2018.08.09
C. The Phone Number  (0) 2018.08.09
B. The Bits  (0) 2018.08.09

+ Recent posts