#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int N, L, U;
vector<int> W;
bitset<1000> INF;
bitset<1000> DP(int i, int sum, bitset<1000> choosen) {
if (sum>U) return INF;
if (sum>=L) return i-1;
if (i == N) return INF;
bitset<1000> res1, res2, res;
choosen[i] = 1;
res1 = DP(i+1, sum + W[i], choosen);
choosen[i] = 0;
res2 = DP(i+1, sum, 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<1000> res = DP(0,0, -1);
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 |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 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 |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 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 |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 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 |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 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 |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |