Submission #62154

# Submission time Handle Problem Language Result Execution time Memory
62154 2018-07-27T14:51:55 Z ernestvw Detecting Molecules (IOI16_molecules) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> solve(int l, int u, vector<int> w) {
	vector<int> ans;
	vector<pair<int, int>> W;
	int n = (int)w.size();
	for(int i = 0; i < n; i++) W.push_back({w[i], i});
	sort(W.begin(), W.end());
	vector<long long> prefix(n+1);
	prefix[0] = 0;
	for(int i = 1; i <= n; i++) prefix[i] = prefix[i-1] + (long long)W[i-1].first;
	for(int i = 0; i < n; i++) {
		long long remove = prefix[i];
		if(prefix[n] - remove < l) continue;
		int cur = i;
		for(int jump = 20; jump >= 0; jump--)
			if((1 << jump) + cur < n and prefix[(1 << jump) + cur + 1] - remove < l)
				cur += (1 << jump);
		cur++;
		if(prefix[cur + 1] - remove > u) continue;
		for(int j = i; j <= cur; j++) ans.push_back(W[j].second);
		return ans;
	}
	return ans;
}

Compilation message

/tmp/ccyeiez8.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status