Advertisement
SorahISA

C. 討論室 (discussion)

Oct 5th, 2022
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | Source Code | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     ios_base::sync_with_stdio(0), cin.tie(0);
  6.    
  7.     int n, k; cin >> n >> k;
  8.    
  9.     vector<pair<int, int>> show(n);
  10.     for (auto &[r, l] : show) cin >> l >> r;
  11.     sort(begin(show), end(show));
  12.    
  13.     int ans = 0;
  14.     multiset<int> st;
  15.     for (int i = 0; i < k; ++i) st.emplace(0);
  16.     for (auto [r, l] : show) {
  17.         auto it = st.upper_bound(l);
  18.         if (it != st.begin()) st.erase(prev(it)), st.emplace(r), ++ans;
  19.     }
  20.     cout << ans << "\n";
  21.    
  22.     return 0;
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement