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>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#define F first
#define S second
//#define endl '\n'
//#define int long long
using namespace std;
vt<int> find_subset(int l, int u, vt<int> ww)
{
    vt<pii> w(sz(ww));
    for(int i = 0; i < sz(ww); i++) w[i] = {ww[i], i};
    sort(all(w));
    ll sum = 0;
    vt<pii> elements;
    for(int i = 0; i < sz(w) && sum + w[i].F <= l; i++)
        sum += w[i].F, elements.pb(w[i]);
    for(int i = sz(w) - 1, j = sz(elements) - 1; i >= 0 && j >= 0 && sum < l; i--, j--)
    {
        sum -= elements[j].F, sum += w[i].F;
        elements[j] = w[i];
    }
    if (sz(elements) == 0 && w[0].F > l && w[0].F < u) return {w[0].S};
    if (sum < l) return {};
    vt<int> ans;
    for(int i = 0; i < sz(elements); i++) ans.pb(elements[i].S);
    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... |