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<int>arr;
int n;
int mx=0;
int dp[105][1005];
int f(int idx,int x,vector<int>vec,vector<int>kolku)
{
if(idx==n)
{
arr=vec;
return 0;
}
if(dp[idx][x]!=-1)return dp[idx][x];
int rez=0;
rez=max(rez, f(idx+1,x,vec,kolku));
if(x+kolku[idx]<=mx)
{
vector<int>pom;
pom=vec;
pom.push_back(idx);
rez=max(rez, f(idx+1,x+kolku[idx],pom,kolku)+kolku[idx]);
}
return dp[idx][x]=rez;
}
vector<int> find_subset(int l, int u, vector<int> w)
{
memset(dp,-1,sizeof dp);
vector<int>v;
mx=u;
n=(int)w.size();
int kol=0;
kol+=f(0,0,v,w);
int sum=0;
for(int i=0;i<n;i++)
{
sum+=w[i];
}
if(sum<l)
{
return {};
}
if(kol<l)
{
return { };
}
else
return arr;
}
# | 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... |