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;
typedef long long ll;
const int max_n = 100000;
vector<int> find_subset(int l, int u, vector<int> w)
{
int n = w.size();
vector<ll> pref(n+1);
for (int i = 0; i < n; i++)
pref[i+1] = pref[i] + w[i];
unordered_map<ll, bitset<max_n>> subsets;
subsets[0] = bitset<max_n>(0);
for (int i = 0; i < n; i++)
{
vector<pair<ll, bitset<max_n>>> new_subsets;
vector<ll> too_smol;
for (auto [sum, subset] : subsets)
{
subset[i] = 1;
if (sum + w[i] <= u)
new_subsets.push_back({sum + w[i], subset});
if (sum + pref[n] - pref[i+1] < l)
too_smol.push_back(sum);
}
for (ll sum : too_smol)
subsets.erase(sum);
for (auto [sum, subset] : new_subsets)
{
subsets[sum] = subset;
if (l <= sum)
{
vector<int> res;
for (int j = 0; j <= i; j++)
if (subset[j])
res.push_back(j);
return res;
}
}
}
return vector<int>(0,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... |