Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- using namespace std;
- int main()
- {
- int
- n;
- int max =
- 0;
- cin >> n;
- vector<int> a(n);
- vector<int>b(n);
- for (int i = 0; i < n; i++)
- {
- cin >> a[i] >>b[i];
- }
- sort(a.begin(),
- a
- .end
- ());
- sort(b.begin(),
- b
- .end
- ());
- int j =
- 0;
- int c =
- 0;
- for (int i = 0; i < n; i++)
- {
- if (a[i] <= b[j])
- {
- c++;
- if (c > max)
- {
- max =
- c;
- }
- } else
- {
- while (a[i] == b[j])
- {
- c--;
- j++;
- }
- if (a[i] > b[j])
- {
- c--;
- j++;
- }
- i--;
- }
- }
- cout << max;
- }
Advertisement
Add Comment
Please, Sign In to add comment