#include<bits/stdc++.h>
#include "molecules.h"
#define ll long long
#define mp make_pair
using namespace std;
typedef pair<int, int> pii;
vector<int> find_subset(int l, int u, vector<int>& w)
{
vector<int> ans;
set<pii, greater<pii>> _Max, Max;
set<pii> Min, _Min;
int n; ll s = 0;
pii top;
n = w.size();
for(int i = 0; i < n; ++i) {
if(s + w[i] <= l) Min.insert(mp(w[i], i)), Max.insert(mp(w[i], i)), s += w[i];
else _Max.insert(mp(w[i], i)), _Min.insert(mp(w[i], i));
}
while(s < l || s > u) {
if(s < l) {
top = *Min.begin();
Min.erase(top), Max.erase(top);
s -= top.first;
_Max.insert(top), _Min.insert(top);
top = *_Max.begin();
s += top.first;
_Min.erase(top), _Max.erase(top);
Max.insert(top), Min.insert(top);
} else {
top = *Max.begin();
s -= top.first;
Min.erase(top), Max.erase(top);
_Min.insert(top), _Max.insert(top);
top = *_Min.begin();
_Min.erase(top), _Max.erase(top);
s += top.first;
Max.insert(top), Min.insert(top);
}
}
for(pii v: Max) ans.push_back(v.second + 1);
return ans;
}
Compilation message
/tmp/ccBT0kUr.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status