题解
2024-03-17 19:43:36
发布于:河北
3阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int a[N];
int main(){
int m; cin>>m;
while(m--){
int n, k, d, w;
cin>>n>>k>>d>>w;
for(int i=0; i<n; i++){
cin>>a[i];
}
int cnt = 1;
int rest = k;
int now = a[0];
int end = now + w + d;
for(int i=0; i<n; i++){
if(rest > 0 && a[i] >= now && a[i] <= end){
rest--;
}
else if(rest == 0){
cnt++;
now = a[i];
end = now + w + d;
rest = k-1;
}
else if(a[i] > end){
cnt++;
now = a[i];
end = now + w + d;
rest = k-1;
}
}
cout << cnt << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个