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"
using namespace std;
int dp[10001][10001], pre[10001][10001];
vector<int> find_subset(int l, int u, vector<int> w) {
int n = (int)w.size();
for (int i = 1; i <= n; i++){
for (int j = 0; j <= u; j++){
dp[i][j] = dp[i - 1][j];
pre[i][j] = pre[i - 1][j];
}
if (w[i - 1] <= u){
dp[i][w[i - 1]] = i;
if (w[i - 1] >= l){
return {i-1};
}
pre[i][w[i - 1]] = (int)1e9;
}
if (w[i - 1] == 0)continue;
if (w[i - 1] > u)continue;
for (int j = 1; j + w[i-1] <= u; j++){
if (dp[i-1][j]){
dp[i][j + w[i-1]] = i;
pre[i][j + w[i - 1]] = dp[i-1][j];
}
if (dp[i][j + w[i-1]] && j + w[i-1] >= l && j + w[i-1] <= u){
int W = j + w[i - 1];
vector<int>ans;
while(i != (int)1e9){
ans.push_back(i-1);
i = pre[i][W];
W -= w[ans.back()];
}
return ans;
}
}
}
return std::vector<int>(0);
}
# | 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... |