This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |