This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
* Author : shora
*/
#include <bits/stdc++.h>
#define print(_v) for (auto &_ : _v) {cerr << _ << ' ';} cerr << endl;
#include "molecules.h"
using namespace std;
using ll = long long;
const int oo = 1e9;
const int N = 1e4, U = 1e4;
int dp[U + 1];
int n;
vector<int> find_subset(int l, int u, vector<int> a) {
n = a.size();
a.insert(a.begin(), 0);
sort(a.begin() + 1, a.end());
vector<int> pre(n+1), suf(n+1);
for (int i = 1; i <= n; ++i) {
pre[i] = pre[i-1] + a[i];
suf[i] = suf[i-1] + a[n-i+1];
}
vector<int> res;
for (int k = 1; k <= n; ++k) {
if (l <= suf[k] && pre[k] <= u) {
for (int i = 0; i <= k; ++i) if (l <= pre[i] + suf[k-i] && pre[i] + suf[k-i] <= u) {
int sum = 0;
for (int j = 1; j <= i; ++j) res.push_back(j-1), sum += a[j];
for (int j = 1; j <= k-i; ++j) res.push_back(n-j), sum += a[n-j+1];
assert(l <= sum && sum <= u);
return res;
}
}
}
return res;
}
# | 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... |