제출 #1263084

#제출 시각아이디문제언어결과실행 시간메모리
1263084sohamsen15Rice Hub (IOI11_ricehub)C++20
100 / 100
12 ms1864 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; using ll = long long; int besthub(int n, int _, int aa[], ll b) { vector<int> a(n + 1); for (int i = 1; i <= n; i++) a[i] = aa[i - 1]; int r = 0, m = 0; bool w = false; vector<ll> p(n + 1); p[0] = 0; for (int i = 1; i <= n; i++) p[i] = a[i] + p[i - 1]; for (int l = 1, u = 1, v = n; l <= n; l++, u = l, v = n) while (u <= v) m = (u + v) / 2, w = (a[l + (m - l) / 2] * (2 * (l + (m - l) / 2) + 1 - l - m) + (p[m] + p[l - 1] - 2 * p[l + (m - l) / 2]) <= b), r = w ? max(r, m - l + 1) : r, u = w ? (m + 1) : u, v = !w ? (m - 1) : v; return r; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...