Submission #137007

#TimeUsernameProblemLanguageResultExecution timeMemory
137007AyaBenSaadRice Hub (IOI11_ricehub)C++14
68 / 100
1076 ms3392 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int R, int L, int X[], long long B){ long long sum[R+2], a[R+2]; sum[0] = 0, a[0] = 0; for (int i = 1; i <= R; i++) a[i] = X[i-1], sum[i] = sum[i-1] + a[i]; int ans = 1; for (int l = 1; l <= R; l++) { for (int r = l+ans; r <= R; r++){ int mid = (l+r) >> 1; long long costleft = (mid-l)*a[mid] - (sum[mid-1]-sum[l-1]); long long costright = (sum[r]-sum[mid]) - (r-mid)*a[mid]; if(costleft + costright <= B) 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...