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"
struct masivs{int val;int poz;};
masivs ab[1000006];
using namespace std;
int i,j,n,m,mas[1000006][2];
vector<int> xx;
bool c1(masivs maz,masivs liel)
{
if (maz.val==liel.val)
{
return maz.poz<liel.poz;
}
return maz.val<liel.val;
}
vector<int> find_subset(int l, int u, vector<int> w)
{
i=0;
while (i<=u)
{
mas[i][0]=-1;
i++;
}
/*i=l;
while (i<=u)
{
mas[i][0]=-2;
i++;
}*/
mas[u][0]=-2;
i=0;
n=w.size();
while (i<n)
{
ab[i].val=w[i];
ab[i].poz=i;
i++;
}
sort(ab,ab+n,c1);
i=n-1;
while (i>=0)
{
j=0;
while (j+ab[i].val<=u)
{
if (mas[j+ab[i].val][0]!=-1&&mas[j][0]==-1)
{
mas[j][0]=j+ab[i].val;
mas[j][1]=ab[i].poz;
if (j<=u-l)
{
while (j<u)
{
xx.push_back(mas[j][1]);
j=mas[j][0];
}
return xx;
}
}
j++;
}
i--;
}
return vector<int>(0);
}
# | 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... |