#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int N, L, U;
vector<int> W;
bitset<100> INF;
bitset<100> DP(int i, int sum, bitset<100> choosen) {
if (sum>U) return INF;
if (sum>=L) return i-1;
if (i == N) return INF;
bitset<100> res1, res2, res;
res1 = DP(i+1, sum, choosen);
choosen[i] = 1;
res2 = DP(i+1, sum + W[i], choosen);
if (res1.count()>res2.count()) res = res1;
else res = res2;
return res;
}
vector<int> find_subset(int l, int u, vector<int> w) {
N = w.size(); L = l; U = u; W = w;
bitset<100> res = DP(0,0, -1);
if (!res.count()) return vector<int>(0);
vector<int> Ans(res.count());
for (int i = 0, j = 0; i<N; ++i) {
if (res[i]) {
Ans[j] = i;
++j;
}
}
return Ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
256 KB |
sum of weights should be in [302..304] but it is 150 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |