Submission #772868

#TimeUsernameProblemLanguageResultExecution timeMemory
772868Tkm_algoDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
// #include "molecules.h

using namespace std;
using ll = long long;
const int N = 5e5 + 10;

vector<int> find_subset(int l, int u, vector<int> w) {
	vector<pair<int, int>> v;
	int n = w.size();
	for (int i = 0; i < n; i++) {
		v.push_back({w[i], i});
	}
	sort(v.begin(), v.end());
	int lf = -1, r = -1;
	ll sm = 0;
	vector<int> ans;
	while (1) {
		if (sm < l && r < n - 1) {
			r++;
			sm += v[r].first;
		} else {
			if (sm > u && lf < n - 1) {
				lf++;
				sm -= v[lf].first;
			} else {
				if (sm >= l && sm <= u) {
					for (int i = lf + 1; i <= r; i++) {
						ans.push_back(v[i].second);
					}
				}
				break;
			}
		}
	}
	return ans;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int l, u;
	cin >> l >> u;
	int n;
	cin >> n;
	vector<int> w;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		w.push_back(x);
	}
	vector<int> ans = find_subset(l, u, w);
	for (auto x : ans) {
		cout << x << ' ';
	}
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccd4B0TP.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccjpazPQ.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status