Advertisement
Josif_tepe

Untitled

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