-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path1946.cpp
More file actions
38 lines (38 loc) · 1.06 KB
/
Copy path1946.cpp
File metadata and controls
38 lines (38 loc) · 1.06 KB
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
// Copyright@2023 Jihoon Lucas Kim <jihoon.lucas.kim@gmail.com>
// 신입 사원
// https://www.acmicpc.net/problem/1946
#include <iostream>
#include <algorithm>
#include <vector>
// 힌트
// 1. cpp stl sort로 pair vector를 정렬 시 first, second 우선순위로 자동 정렬됨
using namespace std;
int main()
{
int T, N;
cin >> T;
while (T--)
{
cin >> N;
vector<pair<int, int> > v(N);
for (int i = 0; i < N; i++)
{
cin >> v[i].first >> v[i].second;
}
sort(v.begin(), v.end());
// 1. 서류면접 순위가 가장 높은 사람을 먼저 뽑고,
int answer = 1;
int index = v[0].second;
for (int i = 1; i < N; i++)
{
// 2. 이후 면접 순위가 앞의 통과자들의 면접 순위보다 높은 사람을 뽑으면서, 최소 면접 순위를 갱신함
if (v[i].second < index)
{
answer += 1;
index = v[i].second;
}
}
cout << answer << endl;
}
return 0;
}