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 "molecules.h"
#include "bits/stdc++.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<bool> dp(u+1, false);
vector<int> par(u+1);
dp[0] = true;
int sum = 0, n = w.size();
for (int j = 0; j < n; j++){
int x = w[j];
for (int i = sum; i >= 0; i--)
if (i+x <= u and !dp[i+x] and dp[i]){
dp[i+x] = true;
par[i+x] = j;
}
sum = min(u, sum+x);
}
for (int i = l; i <= u; i++)
if (dp[i]){
vector<int> answer;
int j = i;
while (j){
answer.push_back(par[j]);
j -= w[par[j]];
}
return answer;
}
return vector<int>{};
}
# | 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... |