慢慢调
#include<cstdio>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int MAXN=6e5;
ll a[MAXN];
ll tmp[MAXN];
ll m;//取的对数
ll testVal(ll lTmp,ll rTmp,ll T){//测试校验值
for(ll i=lTmp;i<=rTmp;i++){
tmp[i]=a[i];
}
sort(tmp+lTmp,tmp+rTmp+1);
ll delta=0;
ll tmpAns=0;
while(rTmp-delta>lTmp+delta){
ll nowVal=tmp[rTmp-delta]-tmp[lTmp+delta];
nowVal=nowVal*nowVal;
tmpAns+=nowVal;
delta++;
if(tmpAns&&delta==m)break;
}
return tmpAns;
}
ll n;
bool check(ll lTmp,ll rTmp,ll T){//判断区间校验值
if(rTmp>n)return false;
ll tmpAns=testVal(lTmp,rTmp,T);
if(tmpAns>T){
return false;
}
return true;
}
int main(){
int K;
scanf("%d",&K);
while(K--){
ll t;
scanf("%lld%lld%lld",&n,&m,&t);
for(ll i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
ll L=1,R=1,p=1,ans=0;
while(R<=n){
while(p){
if(check(L,R+p,t)){
R+=p;
p*=2;
}else{
p/=2;
if(!p)break;
}
};
ans++;
L=R+1;
R=L;
p=1;
}
cout<<ans<<endl;
}
return 0;
}