-
Notifications
You must be signed in to change notification settings - Fork 1
/
foco.cpp
41 lines (27 loc) · 706 Bytes
/
foco.cpp
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 <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
int main(void)
{
int n, a, b, r, e;
while (scanf ("%d", &n) != EOF) {
vii focos;
for (int i = 0; i < n; i++) {
scanf ("%d %d", &a, &b);
focos.push_back(make_pair(a, b));
}
sort(focos.begin(), focos.end());
r = 1;
__typeof(focos.begin()) it = focos.begin();
while (it != focos.end()) {
e = it->second;
while (it != focos.end() && it->first <= e) it++;
if (it != focos.end()) r++;
}
printf ("%d\n", r);
}
return 0;
}