# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125576 | 2019-07-06T02:02:04 Z | ksmzzang2003 | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KB |
#include "ricehub.h" #include <bits/stdc++.h> #define MAXN 100005 typedef long long ll; static int N; ll X[MAXN],S[MAXN]; ll f(int s,int e) { int t = (s+e)/2; return S[e] - S[t] - X[t]*(e-t) +(t-s) *X[t] - (S[t-1]-S[s-1]); } int besthub(int n, int L, int x[], ll B) { N = n ; for(int i=0;i<N;i++) X[i+1] = x[i]; for(int i=1;i<=N;i++) S[i] = S[i-1] + X[i]; int s=1, e = 1,ans = -1987654321; while(1) { if(s+1<=e && f(s,e)>B) s++; ans = max(ans,e-s+1); e++; if(e>N) break; } return ans; }