Josif_tepe

Untitled

Dec 3rd, 2025
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <unordered_map>
  5. using namespace std;
  6. int main(){
  7.     ios_base::sync_with_stdio(false);
  8.     int n;
  9.     cin >> n;
  10.    
  11.     map<int, int> mapa;
  12.    
  13.     for(int i = 0; i < n; i++) {
  14.         int a, b;
  15.         cin >> a >> b;
  16.        
  17.         mapa[a]++;
  18.         mapa[b + 1]--;
  19.     }
  20.    
  21.     int res = 0;
  22.     int cnt = 0;
  23.     for(pair<int, int> p: mapa) {
  24.         cnt += p.second;
  25.         res = max(res, cnt);
  26.     }
  27.    
  28.     cout << res << endl;
  29.  
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment