-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1946.cpp
More file actions
50 lines (42 loc) · 858 Bytes
/
1946.cpp
File metadata and controls
50 lines (42 loc) · 858 Bytes
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
40
41
42
43
44
45
46
47
48
49
50
/**
* @file 1946.cpp
* @brief 신입 사원 - 그리디
* @author Sam Kim (samkim2626@gmail.com)
*/
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<pair<int, int>> v;
for (int i = 0; i < n; i++)
{
int f, s;
cin >> f >> s;
v.push_back(make_pair(f, s));
}
sort(v.begin(), v.end());
int min = v[0].second;
int cnt = 1;
for (int i = 1; i < n; i++)
{
if (min > v[i].second)
{
min = v[i].second;
cnt++;
}
}
cout << cnt << '\n';
}
return 0;
}