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 "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<int> find_subset(int l, int u, vector<int> w)
{
int r = u;
int n = w.size();
set<pair<ll, ll>> s;
ll sum = 0;
for (int i = 0; i < n; i++)
{
s.insert({w[i], i});
sum += w[i];
}
vector<bool> vis(n, 1);
while (sum > r)
{
ll dif = sum - r;
auto it = s.lower_bound({dif, -1});
if (it != s.end() && (sum - (*it).first) >= l && (sum - (*it).first) <= r)
{
pair<ll, ll> x = *it;
sum -= x.first;
vis[x.second] = 0;
break;
}
else
{
pair<ll, ll> x = *s.begin();
sum -= x.first;
vis[x.second] = 0;
s.erase(x);
}
}
vector<int> ans;
if (sum < l)
return ans;
for (int i = 0; i < n; i++)
{
if (vis[i])
ans.push_back(i);
}
return ans;
}
# | 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... |