Is there any problem of the Sample IO? I think we can only put 3,4,5 into the storage as m=1.
- 添加评论
Is there any problem of the Sample IO? I think we can only put 3,4,5 into the storage as m=1.
using namespace std;
int N,M,H,R; vector diskr; int howmany(int base){ int high=diskr.size(); int len=0; for(int i=base;i(i+R-base)) ||(i-1>=base)&&(diskr[i]-diskr[i-1])>M){ len=i-base; break; } } return len; } int main(){ cin>>N>>M>>H>>R;
int r;
for(int i=0;i<N;i++){
cin>>r;
diskr.push_back(r);
}
sort(diskr.begin(),diskr.end());
int sum=0;
int index=0;
while(howmany(index)!=0){
int a=howmany(index);
index+=a;
sum+=a;
}
cout<<sum<<endl;
// while(1);
}
3, 4, 5, 1 is a solution. 1 - 5 = -4 > 1.
something wrong, right?