Submission #998308

#TimeUsernameProblemLanguageResultExecution timeMemory
998308AlfraganusRice Hub (IOI11_ricehub)C++17
100 / 100
13 ms4448 KiB
#include <bits/stdc++.h> #include "ricehub.h" using namespace std; int besthub(int n, int l, int a[], long long b){ vector<long long> pref(n + 1); for(int i = 1; i <= n; i ++) pref[i] = pref[i - 1] + a[i - 1]; auto good = [&](int x){ for(int i = 0; i < n - x + 1; i ++){ long long middle = a[i + x / 2], sum = middle * (x / 2 + 1) - pref[i + x / 2 + 1] + pref[i] + pref[i + x] - pref[i + x / 2 + 1] - middle * (x - x / 2 - 1); if(sum <= b) return true; } return false; }; int left = 1, right = n; while(left < right){ int mid = (left + right + 1) >> 1; if(good(mid)) left = mid; else right = mid - 1; } return left; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...