-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB_Equalize.cpp
52 lines (52 loc) · 943 Bytes
/
B_Equalize.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef unordered_map<ll, ll> mpp;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define fr(i, a, b) for (ll i = a; i < b; i++)
#define get(a) \
for (auto &i : a) \
cin >> i
void wushangclan()
{
int n;
cin>>n;
vl v(n);
get(v);
sort(v.begin(),v.end());
queue<ll> q;
vector<int> ans1;
ll prev=-1,cnt=0,ans=0;
ll k=0;
fr(i,0,n){
while(!q.empty()&& v[i]-q.front()>=n){
q.pop();
cnt--;
k++;
}
if(prev!=v[i]){
q.push(v[i]);
cnt++;
}
ans=max(ans,cnt);
prev=v[i];
k--;
}
cout<<ans<<endl;
}
int main()
{
int t;
cin >> t;
while (t--)
{
wushangclan();
}
return 0;
}