Submission #758568

#TimeUsernameProblemLanguageResultExecution timeMemory
758568JellyTheOctopusDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
// IOI 2016 Day 1 Problem 1
// Detecting Molecules
// https://oj.uz/problem/view/IOI16_molecules

#include <bits/stdc++.h>
using namespace std;

#define f first
#define s second

vector<int> find_subset(int l, int u, vector<int> w) {
	int N = (int)w.size();
	vector<pair<int, int>> valWeight(N);
	for (int i = 0; i < N; i++) {
		valWeight[i] = {w[i], i};
	}
	sort(valWeight.begin(), valWeight.end());
	deque<int> dq;
	long long curSum = 0;
	int i = 0;
	while (i < N) {
		if (l <= curSum && curSum <= u) {
			break;
		}
		if (curSum < l) {
			curSum += valWeight[i].f;
			dq.push_back(i);
			i++;
			continue;
		}
		if (curSum > u) {
			curSum -= valWeight[dq.front()].f;
			dq.pop_front();
		}
	}
	vector<int> ans;
	while (!dq.empty()) {
		ans.push_back(valWeight[dq.front()].s);
		dq.pop_front();
	}
	return ans;
}

int main() {
	vector<int> ans = find_subset(14, 15, {5, 5, 6, 6});
}

Compilation message (stderr)

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