제출 #1221186

#제출 시각아이디문제언어결과실행 시간메모리
1221186SpyrosAliv쌀 창고 (IOI11_ricehub)C++20
17 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int besthub(int R, int L, int X[], ll B) { vector<ll> 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) { ll toL = max(0LL, (ll)(i - l)); ll toR = max(0LL, r - l + 1 - toL); totDis += toL * (coords[i] - coords[i-1]) - toR * (coords[i] - coords[i-1]); } r = max(r, i); while (totDis > b) { totDis -= abs(coords[i] - coords[l]); l++; } while (r < n-1 && (abs(coords[r+1] - coords[i]) <= abs(coords[i] - coords[l]) || (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...