# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434587 | Kanaifu | Detecting Molecules (IOI16_molecules) | C++14 | 7 ms | 8016 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>
#include "molecules.h"
//#include "grader.cpp"
using namespace std;
#define pb push_back
#define x first
#define y second
vector<int> find_subset(int l, int u, vector<int> w)
{
vector <int> ret;
pair<int,int> dp[1001][1001];
for (int i=0; i<=1000; i++)
{
dp[i][0] = {1, -1};
for (int j=1; j<=1000; j++)
{
dp[i][j] = {0, -1};
}
}
for (int i=0; i<w.size(); i++)
{
for (int j=u; j>=0; j--)
{
if (i>0)
{
dp[i][j] = dp[i-1][j];
}
if (dp[i][j].x)
{
if (j+w[i]<=u)
{
dp[i][j+w[i]] = {1, i};
}
}
}
}
for (int j=l; j<=u; j++)
{
if (dp[w.size()-1][j].x)
{
int poz = w.size()-1;
int weight = j;
while (dp[poz][weight].y != -1)
{
int newpoz = dp[poz][weight].y;
ret.pb(newpoz);
if (newpoz==0)
{
break;
}
weight -= w[newpoz];
poz = dp[newpoz][weight].y;
}
break;
}
}
return ret;
}
/*
4 15 17
6 8 8 7
*/
Compilation message (stderr)
# | 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... |