Submission #587917

#TimeUsernameProblemLanguageResultExecution timeMemory
587917shrimbDetecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms212 KiB
#include "bits/stdc++.h"
#include "molecules.h"

using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	int n = w.size();
	pair<int,int> v[n];
	for (int i = 0 ; i < n ; i++) {
		v[i] = {w[i], i};
	}
	sort(v, v + n);

	set<pair<int,int>> s = {{0,0}};

	int sm = 0;

	vector<int> ret;

	for (int i = 0 ; i < n ; i++) {
		sm += v[i].first;
		s.insert({sm, i + 1});
		auto it = s.lower_bound({sm - u, -INT_MAX});
		if (it != s.end()) {
			if (sm - it -> first >= l and sm - it -> first <= u) {
				for (int j = it -> second ; j <= i ; j++) {
					ret.push_back(v[j].second);
					return ret;
				}
			}
		}
	}
	return {};
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...