Advertisement
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, t;
- cin >> n >> t;
- vector<int> left(n), right(n);
- for(int i = 0; i < n; i++)
- cin >> left[i] >> right[i];
- int ans = 0;
- for(int k = 0; k < n; k++)
- {
- for(int z = 0; z <= 1; z++)
- {
- int i = left[k] - z;
- int count = 0;
- for(int j = 0; j < n; j++)
- {
- if (left[j] < i && i+t-1 < right[j]) count--;
- else if (i <= left[j] && i + t - 1 >=right[j]) count++;
- //cout << i << ' ' << left[j] << ' ' << right[j] << ' ' << count << '\n';
- }
- ans= max(ans, count);
- }
- }
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement