-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterval.cpp
More file actions
40 lines (37 loc) · 722 Bytes
/
interval.cpp
File metadata and controls
40 lines (37 loc) · 722 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
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<pair<int,int>> x;
int main(){
int n;
cin >> n;
for (int i=0;i<n;i++){
int s,t;
cin >> s;
cin >> t;
x.push_back(make_pair(t,s));
}
sort(x.begin(),x.end());
int ans = 1;
auto p = x.begin();
auto tmp = x.begin();
tmp++;
while(1){
if (tmp == x.end()) break;
if ((*tmp).first == (*p).first){
tmp++;
continue;
}
if ((*tmp).second < (*p).second){
tmp++;
continue;
}
else {
ans++;
p = tmp;
tmp++;
}
}
cout << ans << "\n";
}