이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <utility>
#include <set>
#include <deque>
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
int n = w.size();
std::vector<int> rvcord(n);
{
std::vector<std::pair<int, int>> incw(n);
for (int i = 0; i < n; ++i) incw[i] = {w[i], i};
std::sort(incw.begin(), incw.end());
for (int i = 0; i < n; ++i) rvcord[i] = incw[i].second;
std::sort(w.begin(), w.end());
}
std::sort(w.begin(), w.end());
long long s = 0, i;
std::deque<int> lo, hi;
for (i = 0; i < (int)w.size(); ++i)
if (s + w[i] <= u) s += w[i], lo.push_back(i);
else break;
for (int j = i; j < (int)w.size(); ++j) hi.push_front(j);
while (s < l && lo.size() && hi.size())
{
long long d = w[hi.front()] - w[lo.front()];
if (d <= 0) break;
s += d;
lo.push_back(hi.front());
hi.pop_front(); lo.pop_front();
}
if (s < l) return std::vector<int>();
std::vector<int> result(lo.begin(), lo.end());
for (auto &x : result) x = rvcord[x];
return result;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |