#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++;
}
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)
{
//cout << i << " " << ab[i].val << " " << ab[i].poz << " " << j << "\n";
mas[j][0]=j+ab[i].val;
mas[j][1]=ab[i].poz;
}
j++;
}
if (mas[0][0]!=-1)
{
j=1;
while (mas[j][0]!=-2)
{
xx.push_back(mas[j][1]);
j=mas[j][0];
}
return xx;
}
i--;
}
return vector<int>(0);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
372 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
508 KB |
Integer 3 violates the range [0, 1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
536 KB |
item #0 is taken twice |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
372 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
508 KB |
Integer 3 violates the range [0, 1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
372 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
508 KB |
Integer 3 violates the range [0, 1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
372 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
508 KB |
Integer 3 violates the range [0, 1] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
372 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
508 KB |
Integer 3 violates the range [0, 1] |
4 |
Halted |
0 ms |
0 KB |
- |