Untitled
user_5668965
c_cpp
10 days ago
605 B
1
Indexable
Never
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } sort(a.begin(), a.end()); a.resize(unique(a.begin(), a.end()) - a.begin()); int pnt = 0, ans = 0; for (int i = 0; i < a.size(); i++) { while(a[i] - a[pnt] >= n) { pnt++; } ans = max(ans, i - pnt + 1); } cout << ans << endl; } signed main() { int t = 1; cin >> t; for (int i = 0; i < t; ++i) { solve(); } return 0; }
Leave a Comment