#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,N) for(ll i = 0; i < N; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#include "molecules.h"
vector<int> find_subset(int l, int u, vector<int> W) {
vector<pair<bool, int>> dp(u+1);
dp[0].F = 1;
vector<int> res;
pair<bool,int> yes = {0,0};
FOR(i, W.size()) {
for(int w = u; w > 0; w--) {
if (w-W[i] >= 0 && dp[w].F != 1) {
if (dp[w-W[i]].F) {
dp[w] = {1, i};
}
}
if (l <= w && w <= u && dp[w].F) {
yes = {1, w};
break;
}
}
if (yes.F) break;
}
if (!yes.F) return res;
while(yes.S != 0) {
res.push_back(dp[yes.S].S);
yes.S = yes.S - W[dp[yes.S].S];
}
return res;
}
Compilation message (stderr)
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |