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;
#define MOD 1000000007
#define mxn 100005
#define mxm 105
#define f first
#define s second
#define pb push_back
#define es " "
#define endl '\n'
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
typedef pair<string, string> pii;
typedef pair<int, pii> pip;
int resp;
ll prefix[mxn], v[mxn];
ll testa(int i, int j){
int med=(i+j)/2;
ll sum=((prefix[j]-prefix[med])-v[med]*(j-med))+((med-i)*v[med]-(prefix[med-1]-prefix[i-1]));
return sum;
}
int besthub(int n, int l, int x[], ll b){
for(int i=1; i<=n; i++){
v[i]=x[i-1];
prefix[i]=prefix[i-1]+v[i];
}
for(int i=1; i<=n; i++){
int ini=i, fim=n, meio;
while(ini<=fim){
meio=(ini+fim)/2;
if(testa(i, meio)<=b){
resp=max(resp, meio-i+1);
ini=meio+1;
}else{
fim=meio-1;
}
}
}
return resp;
}
# | 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... |