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>
using namespace std;
const int N = 1010;
bool dp[110][N];
vector<int> find_subset(int l, int u, vector<int> a) {
a.push_back(0);
sort(a.begin(), a.end());
while(a.back() > u) a.pop_back();
int n = a.size() - 1;
for(int i = 1; i <= n; i++)
if(l <= a[i] && a[i] <= u)
return {i};
dp[0][0] = 1;
for(int i = 1; i <= n; i++) {
for(int j = 0; j <= u; j++) {
dp[i][j] = dp[i - 1][j];
if(j >= a[i])
dp[i][j] |= dp[i - 1][j - a[i]];
}
}
int w = -1;
for(int i = l; i <= u; i++)
if(dp[n][i]) w = i;
if(w == -1) return {};
vector<int> v;
for(int i = n; i >= 1; i--) {
if(w >= a[i] && dp[i - 1][w - a[i]]) {
v.push_back(i);
w -= a[i];
}
}
return v;
}
# | 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... |