#include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> result;
int n = w.size();
int dp[n + 1][u + 1];
int back[u+1];
for(int i = 0; i <= n; i++) {
for(int j = 0; j <= u; j++) {
dp[i][j] = -1;
back[j] = -1;
}
}
dp[0][0] = 0;
for(int i = 1; i <= n; i++) {
for(int s = 0; s <= u; s++) {
if(s < w[i - 1]) {
dp[i][s] = dp[i - 1][s];
}
else if(dp[i - 1][s - w[i - 1]] != -1) {
dp[i][s] = i;
if(back[s] != -1){
back[s] = i;
}
} else {
dp[i][s] = dp[i - 1][s];
}
}
}
for(int i = l; i <= u; i++) {
if(back[i] != -1) {
int idx = back[i];
int s = i;
while(idx != 0) {
result.push_back(idx - 1);
s -= w[idx - 1];
idx = back[s];
}
break;
}
}
return result;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Contestant can not find answer, jury can |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
336 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
1 ms |
336 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |