https://www.acmicpc.net/problem/1946

 

1946번: 신입 사원

첫째 줄에는 테스트 케이스의 개수 T(1 ≤ T ≤ 20)가 주어진다. 각 테스트 케이스의 첫째 줄에 지원자의 숫자 N(1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개 줄에는 각각의 지원자의 서류심사 성

www.acmicpc.net

 

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
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <utility>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    int N;
    int document, interview;
    int result = 0;
    vector<pair<intint>> grade;
    cin >> T;
    while (T--) {
        cin >> N;
        for (int i = 0; i < N; i++) {
            cin >> document >> interview;
            grade.push_back({ document,interview });
        }
        sort(grade.begin(), grade.end());
        int max_score = grade.front().second;
        for (int i = 0; i < N; i++) {
            if (grade[i].second <= max_score) {
                result++;
                max_score = grade[i].second;
            }
        }
        cout << result << "\n";
        result = 0;
        grade.clear();
    }
}
cs

+ Recent posts