Submission #592732

#TimeUsernameProblemLanguageResultExecution timeMemory
592732MahtimursuRice Hub (IOI11_ricehub)C++17
0 / 100
7 ms888 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int besthub(int R, int L, int X[], long long B) { vector<ll> lft; vector<ll> rgt; int best = 0; int n = R; for (int i = n - 1; i > 0; --i) { rgt.push_back(X[i]); } for (int i = 0; i < n; ++i) { ll leftm = B; int cur = 0; int li = lft.size() - 1; int ri = rgt.size() - 1; while (true) { ll leftd = li >= 0 ? abs(lft[li] - X[i]) : 1e18; ll rightd = ri >= 0 ? abs(rgt[ri] - X[i]) : 1e18; if (min(leftd, rightd) > leftm) break; cur++; if (leftd < rightd) { leftm -= leftd; li--; } else { leftm -= rightd; ri--; } } best = max(best, cur); lft.push_back(X[i]); rgt.pop_back(); } return best; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...