Submission #731009

#TimeUsernameProblemLanguageResultExecution timeMemory
731009NintsiChkhaidzeRice Hub (IOI11_ricehub)C++17
100 / 100
19 ms3280 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; #include "ricehub.h" ll p[100005],a[100005]; ll cost(int l,int r){ int mid = (l + r)>>1; ll s1 = (mid - l + 1)*a[mid] - p[mid] + p[l - 1]; ll s2 = p[r] - p[mid] - (r - mid)*a[mid]; return s1+s2; } int besthub(int N, int R, int X[], ll B){ for (int i=0;i<N;i++){ a[i] = X[i]; p[i] = X[i]; if (i) p[i] += p[i - 1]; } int r = 0,ans=0; for (int i = 0; i < N; i++){ while (r + 1 < N && cost(i,r + 1) <= B) ++r; ans=max(ans,r-i+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...