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 sz(x) (int)x.size()
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define all(x) x.begin(), x.end()
#define pb push_back
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
struct Molecule {
	int poids, id;
	bool operator < (const Molecule &autre) const {
		if (poids != autre.poids)
			return poids < autre.poids;
		return id < autre.id;
	}
};
vector<int> find_subset(int l, int u, vector<int> w) {
    int nMolecules = sz(w);
    //cout << nMolecules << endl;
    vector<Molecule> molecules(nMolecules);
    for (int ind = 0; ind < nMolecules; ++ind)
    	molecules[ind] = {w[ind], ind};
    sort(all(molecules));
    int fin = 0; long long sum = 0;
    for (int deb = 0; deb < nMolecules; ++deb){
    	if (deb > 0)
    		sum -= molecules[deb - 1].poids;
    	chmax(fin, deb);
    	while (fin < nMolecules && sum < l)
    		sum += molecules[fin++].poids;
    	//cout << sum << " " << deb << " " << fin << endl;
    	if (l <= sum && sum <= u){
    	//	cout << "OUI " << endl;
    		vector<int> subset;
    		for (int ind = deb; ind < fin; ++ind)
    			subset.pb(molecules[ind].id);
    		return subset;
    	}
    }
    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... |