Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0);
- int n, k; cin >> n >> k;
- vector<pair<int, int>> show(n);
- for (auto &[r, l] : show) cin >> l >> r;
- sort(begin(show), end(show));
- int ans = 0;
- multiset<int> st;
- for (int i = 0; i < k; ++i) st.emplace(0);
- for (auto [r, l] : show) {
- auto it = st.upper_bound(l);
- if (it != st.begin()) st.erase(prev(it)), st.emplace(r), ++ans;
- }
- cout << ans << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement