Submission #1221168

#TimeUsernameProblemLanguageResultExecution timeMemory
1221168SpyrosAliv쌀 창고 (IOI11_ricehub)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int besthub(int R, int L, int X[], ll B) { vector<int> coords; int n = R; ll b = B; for (int i = 0; i < n; i++) coords.push_back(X[i]); int maxAns = 0; int l = 0, r = 0; ll totDis = 0; for (int i = 0; i < n; i++) { if (i > 0) { int toL = max(0, i - l); int toR = max(0, r - l + 1 - toL); totDis += toL * (coords[i] - coords[i-1]) - toR * (coords[i] - coords[i-1]); } r = max(r, i); while (r < n-1 && ((abs(coords[r+1] - coords[i]) <= abs(coords[i] - coords[l]) && l < i) || (abs(coords[r+1] - coords[i]) + totDis <= b))) { totDis += abs(coords[r+1] - coords[i]); r++; if (totDis > b) { totDis -= abs(coords[i] - coords[l]); l++; } } maxAns = max(maxAns, r - l + 1); } return maxAns; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...