This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
template <typename T> using Vec = std::vector<T>;
std::vector<int> find_subset(int L, int R, std::vector<int> W) {
const int N = (int)W.size();
Vec<int> dp(R + 1, N);
dp[0] = -1;
for (int i = 0; i < N; ++i) {
for (int j = 0; j <= R - W[i]; ++j) {
if (dp[j] == N) continue;
const int next_w = j + W[i];
if (dp[next_w] == N) dp[next_w] = i;
}
}
for (int answer_w = L; answer_w <= R; ++answer_w) {
if (dp[answer_w] == -1) continue;
Vec<int> answer;
int now = answer_w;
while (now != 0) {
const int new_id = dp[now];
answer.push_back(new_id);
now -= W[new_id];
}
return answer;
}
return {};
}
# | 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... |