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 "molecules.h"
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=1e4+5;
int dp[maxn];
int pos[maxn];
vector < int > sol;
void rijesi(int x){
if(!x){
return;
}
sol.push_back(pos[x]);
rijesi(dp[x]);
}
void dodaj(int x, int poz){
for(int i=maxn-1; i>=x; i--){
if(dp[i]==-1 && dp[i-x]!=-1){
dp[i]=i-x;
pos[i]=poz;
}
}
}
vector < int > find_subset(int l, int u, vector < int > w) {
memset(dp, -1, sizeof(dp));
dp[0]=0;
int n=w.size();
for(int i=0; i<n; i++){
dodaj(w[i], i);
}
for(int i=l; i<=u; i++){
if(dp[i]!=-1){
rijesi(i);
return sol;
}
}
return sol;
}
# | 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... |