Submission #986799

#TimeUsernameProblemLanguageResultExecution timeMemory
986799huutuanRice Hub (IOI11_ricehub)C++14
100 / 100
11 ms3420 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define int long long const int N=1e5+10; int n, a[N], pf[N]; int calc(int l, int r){ int mid=(l+r)>>1; return a[mid]*(mid-l+1)-(pf[mid]-pf[l-1])+(pf[r]-pf[mid])-a[mid]*(r-mid); } int32_t besthub(int32_t R, int32_t L, int32_t X[], int B) { n=R; for (int i=1; i<=n; ++i) a[i]=X[i-1]; partial_sum(a, a+n+1, pf); int ans=0; for (int l=1, r=1; r<=n; ++r){ while (calc(l, r)>B) ++l; ans=max(ans, r-l+1); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...