# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
725351 | AndrijaM | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KiB |
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;
vector<long long>arr;
long long n;
long long dp[10005][10005];
long long f(long long idx,long long x,vector<long long>vec,long long mx,vector<long long>weight)
{
if(idx==n)
{
arr=vec;
return 0;
}
if(dp[idx][x]!=-1)return dp[idx][x];
long long rez=0;
rez=max(rez, f(idx+1,x,vec,mx,weight));
vector<long long>pom;
pom=vec;
pom.push_back(idx);
if(x+weight[idx]<=mx)
rez=max(rez, f(idx+1,x+weight[idx],pom,mx,weight)+weight[idx]);
return dp[idx][x]=rez;
}
vector<long long> find_subset(long long l, long long u, vector<long long> w)
{
memset(dp,-1,sizeof dp);
vector<long long>v;
queue<long long>Q;
n=w.size();
long long kol=f(0,0,v,u,w);
if(kol<l)
{
arr.clear();
}
return arr;
}