# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1186932 | rhm_gan | Detecting Molecules (IOI16_molecules) | C++20 | 205 ms | 496 KiB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dbg(...) 42
#endif
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<bool> dp(u + 1);
dp[0] = 1;
for (int i = 0; i < n; i++) {
for (int j = u - w[i]; j >= 0; j--) {
if (dp[j]) {
dp[j + w[i]] = 1;
}
}
}
vector<int> res;
vector<bool> vis(n);
for (int i = l; i <= u; i++) {
if (dp[i]) {
int x = i;
for (int j = 0; j < n; j++) {
if (x - w[j] >= 0 && dp[x - w[j]] && !vis[j]) {
x -= w[j];
res.push_back(j);
}
}
return res;
}
}
return res;
}
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... |