Submission #418275

#TimeUsernameProblemLanguageResultExecution timeMemory
418275temurbek_khujaevRice Hub (IOI11_ricehub)C++17
0 / 100
3 ms332 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { int ans = 0; int l = 0; int r = 0; for (int i = 0; i < R; i++) { if (i > 0) { B -= 1ll * (X[i] - X[i - 1]) * (i - l); B += 1ll * (X[i] - X[i - 1]) * (r - i); } while (l < i && B < 0) { B += X[i] - X[l]; l++; } while (r < R && B >= X[r] - X[i]) { B -= X[r] - X[i]; r++; } while (r < R && B + X[i] - X[l] >= X[r] - X[i]) { B += 1ll * X[i] - X[l] - X[r] + X[i]; r++; l++; } ans = max(ans, r - l); } 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...