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>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
using namespace std;
int ans;
long long sum[100005];
int besthub(int R, int L, int X[], long long B){
int lp=0,rp=0;
forr(i,0,R){
sum[i]=sum[i-1]+X[i];
}
while(rp<R){
int mid=(lp+rp)/2;
long long cost=X[mid]*(mid-lp)-X[mid]*(rp-mid)-(sum[mid-1]-sum[lp-1])+(sum[rp]-sum[mid]);
if(cost>B){
lp++;
}
else{
ans=max(ans,rp-lp+1);
rp++;
}
}
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... |