aboutsummaryrefslogtreecommitdiff
path: root/02_sorting_and_searching/movie_festival_1629.cpp
blob: 4ec1fca5488bb4fde46eb81a90830f09dab687b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
	size_t n;
	std::cin >> n;
	std::vector<std::pair<int, int>> v(n);
	for (size_t i = 0; i < n; i++)
		std::cin >> v[i].first >> v[i].second;
	std::sort(v.begin(), v.end());
	int e{-1}, s{0};
	for (auto a : v) {
		if (a.first >= e) {
			e = a.second;
			s++;
		}
		e = std::min(e, a.second);
	}
	std::cout << s << "\n";
}

Generated with cgit - Back to sebastiano.tronto.net