Submission #592731

#TimeUsernameProblemLanguageResultExecution timeMemory
592731MahtimursuRice Hub (IOI11_ricehub)C++17
68 / 100
1079 ms1208 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 = 0; vector<ll> dst; for (int j = 0; j < n; ++j) dst.push_back(abs(X[i] - X[j])); sort(dst.begin(), dst.end()); int idx = 0; while (idx < n && dst[idx] <= leftm) { leftm -= dst[idx++]; cur++; } /*while (true) { ll leftd = li >= 0 ? abs(lft[li] - X[i]) : 1e18; ll rightd = ri < (int)rgt.size() ? 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; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:24:13: warning: unused variable 'li' [-Wunused-variable]
   24 |         int li = lft.size() - 1;
      |             ^~
ricehub.cpp:25:13: warning: unused variable 'ri' [-Wunused-variable]
   25 |         int ri = 0;
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...