Sample IO of Disk Storage

0
0

Is there any problem of the Sample IO? I think we can only put 3,4,5 into the storage as m=1.

3 answer(s)

0

include

include

include

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);

}

0

3, 4, 5, 1 is a solution. 1 - 5 = -4 > 1.

0

something wrong, right?

write answer 切换为英文 切换为中文


转发分享