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>
#include "molecules.h"
using namespace std;
const int nax = 1000;
bitset<nax * 500 + 1>dp;
bool taken[nax];
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
dp[0] = 1;
for(int i=0; i<n; ++i) {
dp |= (dp<<w[i]);
}
int st = -1;
for(int x=l; x<=u; ++x) {
if(dp[x]) {
st = x;
break;
}
}
vector<int>ret;
if(st==-1) return ret;
while(st) {
for(int i=0; i<n; ++i) if(!taken[i] && st-w[i]>=0 && dp[st-w[i]]) {
taken[i] = true;
ret.push_back(i);
st -= w[i];
}
}
return ret;
}
# | 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... |