Submission #991579

#TimeUsernameProblemLanguageResultExecution timeMemory
991579thinknoexitRice Hub (IOI11_ricehub)C++17
100 / 100
11 ms3676 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 100100; int n; ll x[N]; ll qs[N]; int besthub(int NN, int L, int X[], ll B) { n = NN; for (int i = 1;i <= n;i++) { x[i] = X[i - 1]; qs[i] = qs[i - 1] + x[i]; } int ans = 0; for (int i = 1, j = 1;i <= n;i++) { while (j < i) { int med = (i + j) / 2; ll suml = qs[med] - qs[j - 1]; ll sumr = qs[i] - qs[med]; if ((x[med] * (med - j + 1) - suml) + (sumr - x[med] * (i - med)) > B) j++; else break; } ans = max(ans, i - j + 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...