Submission #525330

#TimeUsernameProblemLanguageResultExecution timeMemory
525330prvocisloRice Hub (IOI11_ricehub)C++17
100 / 100
13 ms2500 KiB
#include "ricehub.h" #include <algorithm> #include <iostream> #include <string> #include <random> #include <chrono> #include <vector> #include <cmath> #include <set> #include <map> #include <iomanip> #include <queue> #include <bitset> #include <cmath> #include <cassert> typedef long long ll; typedef long double ld; using namespace std; const int maxr = 1e5 + 5; ll pf[maxr]; ll sum(int l, int r) { return pf[r + 1] - pf[l]; } bool check(int r, int l, ll b, int k) { for (int i = 0; i + k <= r; i++) { ll s = sum(i + k - k / 2, i + k - 1) - sum(i, i + k / 2 - 1); if (s <= b) return true; } return false; } int besthub(int r, int l, int x[], ll b) { for (int i = 0; i <= r; i++) pf[i + 1] = pf[i] + x[i]; int lo = 1, hi = r; while (lo < hi) { int mi = (lo + hi + 1) / 2; if (check(r, l, b, mi)) lo = mi; else hi = mi - 1; } return lo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...