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>
#define ll long long
#define pb push_back
#define x first
#define y second
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w)
{
    vector<pair<ll,int>> pw;
    for(int x:w) pw.pb({(ll)(x),int(pw.size())});
    sort(pw.begin(),pw.end());
    ll sum=0;
    int ptr=0;
    vector<int> ans;
    bool flag=0;
    while(ptr<int(pw.size()))
    {
        if(sum+pw[ptr].x<l) sum+=pw[ptr].x, flag=1;
        else if(sum+pw[ptr].x<=u)
        {
            ans.pb(pw[ptr].y);
            return ans;
        }
        else break;
        ans.pb(pw[ptr].y);
        ptr++;
    }
    if(!flag) return {};
    for(int i=0;i<int(ans.size()) && pw.size()-1-i>=ans.size();i++)
    {
        sum+=pw[pw.size()-1-i].x-pw[i].x;
        ans[i]=pw[pw.size()-1-i].y;
        if(sum>=l) 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... |