#include <bits/stdc++.h>
using namespace std;
struct Info {
int PosAvant = -1, TpsArrivee = -1;
bool vu = false;
void entree(int p, int t, bool v) {
PosAvant = p;
TpsArrivee = t;
vu = v;
}
};
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size(), pos = 0;
bool possible = false;
sort(w.begin(), w.end());
Info Tab[u+1];
Tab[0].entree(-1, -1, true);
for(int loop = 0; loop < n; ++loop) {
for(int looping = u; looping >= 0; --looping) {
if(Tab[looping].vu) {
int suivant = looping + w[loop];
if(suivant <= u) {
if(!Tab[suivant].vu) {
Tab[suivant].entree(looping, loop, true);
if(suivant >= l) {
possible = true;
pos = suivant;
break;
}
}
}
}
}
if(possible) {
break;
}
}
vector<int> subset;
while(pos > 0) {
subset.push_back(w[Tab[pos].TpsArrivee]);
pos = Tab[pos].PosAvant;
}
return subset;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Integer 51 violates the range [0, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
0 ms |
348 KB |
Integer 10 violates the range [0, 0] |
4 |
Halted |
0 ms |
0 KB |
- |