Advertisement
Josif_tepe

Untitled

Sep 11th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.    
  9.     map<int, int> mapa;
  10.     for(int i = 0; i < n; i++) {
  11.         int a, b;
  12.         cin >> a >> b;
  13.        
  14.         mapa[a] += 1;
  15.         mapa[b + 1] -= 1;
  16.     }
  17.     int res = 0, sum = 0;
  18.    
  19.     for(auto i : mapa) {
  20.         sum += i.second;
  21.         res = max(res, sum);
  22.     }
  23.     cout << res << endl;
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement