#include "molecules.h"
#include <bits/stdc++.h>
#define int long long
#define moony long long
#define pii pair<int, int>
#define fi first
#define se second
#define ld long double
#define vi vector<int>
#define vii vector<vector<int>>
#define all(v) (v).begin(), (v).end()
#define rep(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define per(i, b, a) for (int i = (b), _a = (a); i >= _a; --i)
using namespace std;
const int INF = 1e15;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pair<int, int>> v;
int n = (int)w.size();
for (int i = 0; i < n; ++i)
v.push_back({w[i], i});
v.push_back({INF, n});
sort(v.begin(), v.end());
int pref = 0, suff = 0;
for (int i = 0; i < n; ++i) {
pref += v[i].first;
suff += v[n - 1 - i].first;
if (pref <= u && suff >= l) {
vector<int> res;
for (int j = i; j < n; ++j) {
if (pref >= l) {
for (int k = j - i; k <= j; ++k)
res.push_back(v[k].second + 1);
return res;
}
pref += v[j + 1].first - v[j - i].first;
}
}
}
return vector<int>();
}
Compilation message
/usr/bin/ld: /tmp/ccyNmU8x.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