#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
bool dp[110][N];
vector<int> find_subset(int l, int u, vector<int> W) {
vector<int> a = {0};
for(int x : W) a.push_back(x);
int n = a.size() - 1;
for(int i = 1; i <= n; i++)
if(l <= a[i] && a[i] <= u)
return {i};
dp[0][0] = 1;
for(int i = 1; i <= n; i++) {
for(int j = 0; j <= u; j++) {
dp[i][j] = dp[i - 1][j];
if(j >= a[i])
dp[i][j] |= dp[i - 1][j - a[i]];
}
}
int w = -1;
for(int i = l; i <= u; i++)
if(dp[n][i]) w = i;
if(w == -1) return {};
vector<int> v;
for(int i = n; i >= 1; i--) {
if(w >= a[i] && dp[i - 1][w - a[i]]) {
v.push_back(i);
w -= a[i];
}
}
return v;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
508 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
640 KB |
Integer 12 violates the range [0, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
508 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
508 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
508 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
484 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
3 ms |
508 KB |
Integer 1 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |