| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 129038 | teomrn | Detecting Molecules (IOI16_molecules) | C++14 | 320 ms | 27512 KiB | 
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>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	int n = w.size();
	map <int, vector <int>> ids;
	for (int i = 0; i < w.size(); i++)
		ids[w[i]].push_back(i);
	sort(w.begin(), w.end());
	vector <long long> sp(n + 1);
	for (int i = 1; i < sp.size(); i++)
		sp[i] = sp[i - 1] + w[i - 1];
	for (int nr = 1; nr <= n; nr++) {
		if (sp[nr] > u || sp[n] - sp[n - nr] < l)
			continue;
		/// acum sunt in bucata buna
		int from = 1;
		while (sp[from + nr - 1] - sp[from - 1] < l)
			from++;
		assert(sp[from + nr - 1] - sp[from - 1] <= u);
		vector <int> ans;
		for (int i = from - 1; i < from + nr - 1; i++) {
			ans.push_back(ids[w[i]].back());
			ids[w[i]].pop_back();
		}
		return ans;
	}
	return vector <int> ();
}
Compilation message (stderr)
| # | 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... | ||||
