# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
821315 | Kerim | Detecting Molecules (IOI16_molecules) | C++17 | 1082 ms | 2388 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 "molecules.h"
#include "bits/stdc++.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<bool> dp(u+1, false);
vector<int> par(u+1);
dp[0] = true;
int sum = 0, n = w.size();
vector<int> ind(n);
for (int i = 0; i < n; i++)
ind[i] = i;
sort(ind.begin(), ind.end(), [&](int x, int y){
return (w[x] < w[y]);
});
for (int j = 0; j < n; j++){
int x = w[ind[j]];
for (int i = sum; i >= 0; i--)
if (i+x <= u and !dp[i+x] and dp[i]){
dp[i+x] = true;
par[i+x] = ind[j];
}
sum = min(u, sum+x);
}
for (int i = l; i <= u; i++)
if (dp[i]){
vector<int> answer;
int j = i;
while (j){
answer.push_back(par[j]);
# | 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... |