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;
using ll = long long;
#include "molecules.h"
#define rep(a) for(ll i = 0; i < a; i++)
#define all(a) begin(a), end(a)
#define sum(a) accumulate(all(a), 0LL)
vector<int> find_subset(int l, int u, vector<int> w){
    ll n = w.size();
    vector<ll> a(n);
    iota(all(a), 0);
    sort(all(a), [&](ll a, ll b){ return w[a] < w[b]; });
    if(w[a[0]] > u) return {};
    if(l > sum(w)) return {};
    ll s = 0, at = n;
    vector<int> ans;
    while(s <= u){
        if(l <= s) return ans;
        ans.push_back(a[--at]);
        s += w[ans.back()];
    }
    n = min<ll>(ans.size(), n - ans.size());
    rep(n){
        s -= w[ans[i]];
        ans[i] = a[i];
        s += w[ans[i]];
        if(s <= u) return ans;
    }
    return {};
}
| # | 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... |