# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434564 | Kanaifu | Detecting Molecules (IOI16_molecules) | C++14 | 7 ms | 8140 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 (dp[i][j].x)
{
if (j+w[i]<=u)
{
dp[i][j+w[i]] = {1, i};
}
}
else if (i>0)
{
dp[i][j] = dp[i-1][j];
}
}
}
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)
{
ret.pb(dp[poz][weight].y);
weight -= w[dp[poz][weight].y];
if (poz==0)
{
break;
}
poz = dp[poz-1][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... |