#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 |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
item #11 is taken twice |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
1 ms |
256 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |