# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1198375 | grafff | Detecting Molecules (IOI16_molecules) | C++20 | 1095 ms | 2372 KiB |
#ifdef molecules.h
#include "molecules.h"
#endif
#include <bits/stdc++.h>
using namespace std;
vector <int> find_subset(int l, int u, vector <int> w){
int n = w.size(), res = 0;
vector <int> dp(u + 1, -2);
dp[0] = -1;
bool flag = false;
for(int i = 0; i < n; i++){
for(int j = u; j >= 0; j--){
if(j - w[i] < 0){
break;
}
if(dp[j - w[i]] > -2){
if(dp[j] == -2){
dp[j] = i;
}
if(j >= l){
res = j;
flag = true;
break;
}
}
}
if(flag){
break;
}
}
vector <int> ans;
int x = dp[res];
while(x >= 0){
ans.push_back(x);
res -= w[x];
x = dp[res];
}
return ans;
}
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... |