Submission #641644

#TimeUsernameProblemLanguageResultExecution timeMemory
641644deviceDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
int main() {
std::vector<int> find_subset(int l, int u, vector<int> w) {
	vector<pair<int,int>> v(n);
	for (int i = 0; i < n; i++) v[i] = w[i], v[i].second = i;
	sort(v.begin(), v.end());
	int cur = 0, ptr = 0;
	for (int i = 0; i < n; i++) {
		cur += v[i].first;
		while (cur > u && ptr <= i) {
			cur -= v[ptr].first;
			ptr++;
		}
		if (cur >= l && cur <= u) {
			vector<int> ret;
			for (int j = ptr; j <= i; j++) ret.push_back(v[j].second);
			return ret;
		}
	}
    return vector<int>(0);
}

Compilation message (stderr)

molecules.cpp: In function 'int main()':
molecules.cpp:5:59: error: a function-definition is not allowed here before '{' token
    5 | std::vector<int> find_subset(int l, int u, vector<int> w) {
      |                                                           ^
molecules.cpp:23:1: error: expected '}' at end of input
   23 | }
      | ^
molecules.cpp:4:12: note: to match this '{'
    4 | int main() {
      |            ^