Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct Movie{
- int start, end;
- bool operator<(const Movie &a) const{
- if(end == a.end){
- return start<a.start;
- }
- return end<a.end;
- }
- };
- int n, k;
- vector<Movie> mv;
- multiset<int, greater<int>> person;
- int ans;
- int main(){
- //freopen("moviefestivalII.in", "r", stdin);
- cin >> n >> k;
- //mv.resize(n+1);
- for(int i=0; i<n; i++){
- int a, b;
- cin >> a >> b;
- mv.push_back({a, b});
- }
- sort(mv.begin(), mv.end());
- for(int i=0; i<k; i++){
- person.insert(0);
- }
- for(Movie m: mv){
- auto it = person.lower_bound(m.start);
- if(it == person.end()){
- continue;
- }
- person.erase(it);
- person.insert(m.end);
- ans++;
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement