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"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) x.begin(),x.end()
using ll=long long;
const ll INF=1LL<<60;
int besthub(int R, int L, int X[], long long B){
vector<ll> cum(R+1,0);
vector<ll> x(R);
rep(i,R){
x[i]=X[i];
cum[i+1]=cum[i]+x[i];
}
ll ok=1,ng=R+1;
while(ng-ok>1){
ll mid=(ok+ng)>>1;
ll half=mid>>1;
bool can=0;
rep(i,R-mid+1){
ll lf=cum[i+half]-cum[i];
ll ri=cum[i+mid]-cum[i+half];
ll rs=0;
if(mid&1)rs-=x[i+half];
if(rs+ri-lf<=B){
can=1;
}
}
if(can)ok=mid;
else ng=mid;
}
return ok;
}
# | 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... |