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 "molesules.h"
#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<Vec<int>> dp(N + 1, std::vector<int>(R + 1, -1));
dp[0][0] = 0;
for (int i = 0; i < N; ++i) {
for (int j = 0; j <= R; ++j) {
if (dp[i][j] == -1) continue;
dp[i + 1][j] = dp[i][j];
if (j + W[i] <= R) dp[i + 1][j + W[i]] = i;
}
}
for (int answer_w = L; answer_w <= R; ++answer_w) {
if (dp[N][answer_w] == -1) continue;
Vec<int> answer;
int now = answer_w, now_id = N;
while (now != 0) {
const int new_id = dp[now_id][now];
answer.push_back(new_id);
now -= W[new_id];
now_id = 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... |