-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcap_so_dp.cpp
More file actions
39 lines (39 loc) · 769 Bytes
/
cap_so_dp.cpp
File metadata and controls
39 lines (39 loc) · 769 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
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<queue>
#include<stack>
#include<string>
using namespace std;
long long mod = 1e9 + 7;
void slove(){
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (auto &x : a)
cin >> x.first >> x.second;
sort(a.begin(), a.end());
int cnt = 1, last = a[0].second;
for (int i = 1; i < n; i++)
{
if (a[i].first > last)
{
cnt++;
last = a[i].second;
}
else if (a[i].second < last)
last = a[i].second;
}
cout << cnt << "\n";
}
int main(){
int t=1;
cin >> t;
while(t--){
slove();
}
return 0;
}