# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
80190 | 2018-10-19T13:44:27 Z | farukkastamonuda | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KB |
#include "ricehub.h" #include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000000 #define md 1000000007 #define li 100005 #define mp make_pair #define pb push_back using namespace std; lo int n,T[10],mx,b,A[li],pre[li],ans; bool chechk(int l,int r){ int mid=(l+r)/2; lo int sum=A[mid]*(mid-l+1)-(pre[mid]-pre[l-1]); sum+=(pre[r]-pre[mid-1])-A[mid]*(r-mid+1); return sum<=b; } lo int besthub(int R,int L,int X[],lo int B){ n=R; for(int i=1;i<=n;i++) A[i]=X[i-1]; mx=L; b=B; for(int i=1;i<=n;i++) pre[i]=pre[i-1]+A[i]; for(int i=1;i<=n;i++){ lo int l=i,r=n; while(l<=r){ int mid=(l+r)/2; if(chechk(i,mid)) l=mid+1; else r=mid-1; } ans=max(ans,l-i); } return ans; }