another 4 sorting and searching problems

This commit is contained in:
2024-06-04 11:04:33 +02:00
parent 4e39870547
commit 7fd24571df
5 changed files with 106 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
// 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;
}