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 "ricehub.h"
#ifdef ONLINE_JUDGE
#include <bits/stdc++.h>
#else
#include"bits/stdc++.h"
#endif
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
long long int arr[R+1],p[R+1]={0};
for(int i=1;i<=R;i++){
arr[i]=X[i-1];
p[i]=p[i-1]+arr[i];
}
int ptr1=1,ptr2=1,ans=1;
while(ptr2<=R){
if(ptr1==ptr2){
ptr2++;
}
int m1=(ptr1+ptr2)/2,m2=m1+(ptr1+ptr2)%2;
long long int td=(p[ptr2]-p[m2-1])-(p[m1]-p[ptr1-1]);
if(td<=B){
ans=max(ans,ptr2-ptr1+1);
ptr2++;
}
else{
ptr1++;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |