Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define f first
- #define s second
- using namespace std;
- typedef pair <int, int> pii;
- const int MAXN = 211111;
- const double eps = 0.5;
- vector <pii> a;
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int n, t;
- cin >> n >> t;
- a.resize(n);
- vector <int> tmp(n);
- for(int i = 0; i < n; i++){
- int l, r;
- cin >> l >> r;
- a[i] = {l, r};
- tmp[i] = l;
- }
- sort(a.begin(), a.end());
- sort(tmp.begin(), tmp.end());
- int ans = 0;
- for(int i = 0; i < n; i++){
- double cur_l = a[i].f - eps, cur_r = a[i].f + t - eps;
- int cur_upper, cur_lower;
- cur_upper = cur_lower = 0;
- for(int j = i; j < n; j++)
- if(a[j].f > cur_l && a[j].s < cur_r)cur_lower++;
- int pos = lower_bound(tmp.begin(), tmp.end(), a[i].f) - tmp.begin();
- for(int j = 0; j < pos; j++)
- if(a[j].s > cur_r)cur_upper++;
- ans = max(ans, cur_lower - cur_upper);
- }
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement