josiftepe

Untitled

Oct 24th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <map>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ios_base::sync_with_stdio(false);
  10.     int n;
  11.     cin >> n;
  12.     map<int, int> c;
  13.     vector<int> v(n + 1);
  14.     // map<key, value> c ,key: type, value: type
  15.     // c["stefan"] = 1
  16.     // cout << c[ime], ime = "stefan"
  17.     for(int i = 0; i < n; ++i) {
  18.         int a, b;
  19.         cin >> a >> b;
  20.         ++c[a];
  21.         --c[b + 1];
  22.     }
  23.     int ret = 0, pref_sum = 0;
  24.     for(map<int, int>::iterator it = c.begin(); it != c.end(); ++it) {
  25.         pref_sum += it->second;
  26.         ret = max(ret, pref_sum);
  27.     }
  28.     cout << ret << endl;
  29.  
  30.     return 0;
Advertisement
Add Comment
Please, Sign In to add comment