Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <iomanip>
- #include <cstring>
- #include <queue>
- #include <set>
- #include <cmath>
- #define ll long long
- using namespace std;
- int main() {
- int t;
- cin >> t;
- while(t--) {
- int n;
- cin >> n;
- vector<int> v(n);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- }
- sort(v.begin(), v.end());
- v.resize(unique(v.begin(), v.end()) - v.begin());
- int j = 0, res = 0;
- for(int i = 0; i < v.size(); i++) {
- while(j < v.size() and v[i] - v[j] >= n) {
- j++;
- }
- res = max(res, i - j + 1);
- }
- cout << res << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement