forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path133.cpp
More file actions
41 lines (37 loc) · 642 Bytes
/
133.cpp
File metadata and controls
41 lines (37 loc) · 642 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
//ac
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
class outpost {
public:
int x, y;
int id;
bool operator < (const outpost &c) const {
return c.x < x;
}
};
int main() {
int n;
scanf("%d", &n);
vector<outpost> mm(n);
for (int i = 0; i < n; ++i) {
scanf("%d %d", &mm[i].x, &mm[i].y);
}
sort(mm.begin(), mm.end());
int maxn = -1;
vector<int> dd(n);
for (int i = n - 1; i >= 0; --i) {
if (mm[i].y > maxn) {
maxn = mm[i].y;
}
dd[i] = maxn;
}
int ret = 0;
for (int i = 0; i < n - 1; ++i) {
if (dd[i + 1] > mm[i].y) ++ret;
}
printf("%d\n", ret);
return 0;
}