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>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	vector<pair<int,int>> v(n);
	for (int i = 0; i < n; i++) v[i] = {w[i],i};
	sort(v.begin(),v.end());
	long long low = v[0].first;
	for (pair<int,int> &p : v) p.first -= low;
	long long sumHigh = 0, sumLow = 0;
	for (int sz = 1; sz <= n; sz++) { //sum + low * sz >= l ?
		sumHigh += v[n-sz].first; sumLow += v[sz-1].first;
		if (sumHigh + low * sz >= l && sumLow + low * sz <= u) { //found an answer
			long long cur = sumLow + low * sz;
			for (int st = 0; st < n; st++) {
				if (st) cur -= v[st-1].first, cur += v[st+sz-1].first;
				if (l <= cur && cur <= u) {
					vector<int> ret;
					for (int j = st; j < st + sz; j++) ret.push_back(v[j].second);
					return ret;
				}
			}
		}
	}
	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... |