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 <iostream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
const int N = w.size();
// assert(N <= 100 && u <= 1000);
VI can(u+1);
VI P(u+1, -1);
can[0] = true;
for (int n = 0; n < N; ++n) {
VI new_can(u+1);
for (int sum = 0; sum <= u; ++sum) {
if ( can[sum] ) {
new_can[sum] = true;
if (sum + w[n] <= u) {
new_can[sum + w[n]] = true;
P[sum + w[n]] = n;
}
}
}
can = new_can;
}
for (int sum = l; sum <= u; ++sum) {
if (can[sum]) {
vector<int> res;
for (int s = sum; s != 0; ) {
int n = P[s];
res.push_back(n);
s -= w[n];
}
return res;
}
}
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... |