29 lines
525 B
C++
29 lines
525 B
C++
// Movie Festival
|
|
|
|
#include<bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
using ll = long long;
|
|
|
|
int main() {
|
|
int n; cin >> n;
|
|
vector<pair<ll, ll>> movies(n);
|
|
for (auto &p: movies) {
|
|
ll a, b; cin >> a >> b;
|
|
p = {b, a};
|
|
}
|
|
int count = 0;
|
|
int current_time = 0;
|
|
std::sort(movies.begin(), movies.end());
|
|
for (auto &[end, start]: movies) {
|
|
if (start >= current_time) {
|
|
current_time = end;
|
|
count++;
|
|
}
|
|
}
|
|
|
|
cout << count << endl;
|
|
|
|
return 0;
|
|
}
|