# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136415 | miguel | 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>
#include<ricehub.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define int ll
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 998244353;
int besthub(int n, int l, int x[], int b){
int s[n+1];
int ans=0;
s[0]=x[0];
s[n]=1000000000000000000;
for(int i=1; i<n; i++) s[i]=s[i-1]+x[i];
for(int i=0; i<n; i++){
int l=0, r=n-i;
while(r-l>1){
int mid=(l+r)>>1;
int start=i, end=i+mid;
int xd=(start+end)/2;
if((x[xd]*(2*xd-start-end)-s[xd-1]+s[start-1]+s[end]-s[xd])<=b) l=mid;
else r=mid;
}
ans=max(ans, l);
}
return ans;
}