Submission #1064409

# Submission time Handle Problem Language Result Execution time Memory
1064409 2024-08-18T12:19:12 Z Rigobertus Detecting Molecules (IOI16_molecules) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include "molecules.h"
#define int long long
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	int n = w.size();
	vector<pair<int, int>> v;
	vector<int> result;
	for (int i = 0; i < n; i++) {
		v.push_back({ w[i], i + 1 });
	}
	sort(w.begin(), w.end());
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum += w[i];
	}
	for (int i = n - 1; i >= 0; i--) {
		if (sum - v[i].first < l) {
			result.push_back(v[i].second);
		}
		else {
			sum -= v[i].first;
		}
	}
	if (sum < l) {
		return {};
	}
	return result;
}

Compilation message

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