# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
383118 | Benmath | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int besthub(int r,long long int l,long long int x[],long long int b){ int maxi=1;
for(int i=0;i<r;i++){
long long int sum2=0;
for(int j=i-1;j>=0;j--){
sum2=sum2+x[i]-x[j];
long long int sum3=0;
for(int k=i;k<r;k++){
sum3=sum3+x[k]-x[i];
long long int sum=sum2+sum3;
if(sum<=b){
int x1=k-j+1;
if(x1>maxi){
maxi=x1;
}
}
}
}
}
return maxi;
}
int main(){
int r;
cin>>r;
long long int l,b;
cin>>l>>b;
long long int x[r];
for(int i=0;i<r;i++){
cin>>x[i];
}
cout<<besthub(r,l,x,b);
}