Submission #1133834

#TimeUsernameProblemLanguageResultExecution timeMemory
1133834domblyRice Hub (IOI11_ricehub)C++20
100 / 100
12 ms1552 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int n, int len, int* a, long long b) { vector<long long> pref(n); for (int i = 0; i < n; i++) { if (i == 0) { pref[i] = a[i]; } else { pref[i] = pref[i - 1] + a[i]; } } auto Can = [&](int l, int r) { int mid = l + r >> 1; long long ll = (long long) a[mid] * (mid - l + 1) - (pref[mid] - (l == 0 ? 0LL: pref[l - 1])); long long rr = pref[r] - pref[mid] - (long long) a[mid] * (r - mid); return ll + rr <= b; }; int ans = 1; for (int i = 0; i < n; i++) { int bot = i, top = n - 1, mx = 0; while (bot <= top) { int mid = bot + top >> 1; if (Can(i, mid)) { mx = mid - i + 1; bot = mid + 1; } else { top = mid - 1; } } ans = max(ans, mx); } 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...