#include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
#define mp make_pair
#define F first
#define S second
using namespace std;
using pii = pair<int,int>;
const int N = 2e5 + 5;
pii A[N];
int m, bit[N*3];
ll qs[N], cp[N];
int pos(ll x){ return upper_bound(cp, cp+m, x) - cp;}
int qry(int i){ int res = 0; for(; i; i-=i&-i) res += bit[i]; return res;}
void upd(int i, int v){ for(; i<=m; i+=i&-i) bit[i] += v;}
int find_subset(int L, int R, int* w, int n, int* I){
for(int i = 0; i<n; ++i) A[i] = mp(w[i], i);
sort(A, A+n);
for(int i = 0; i<n; ++i) qs[i] = w[i];
for(int i = 1; i<n; ++i) qs[i] += qs[i-1];
m = 0;
cp[m++] = 0; for(int i = 0; i<n; ++i){ cp[m++] = qs[i]; cp[m++] = qs[i] - L; cp[m++] = qs[i] - R;}
sort(cp, cp+m); m = unique(cp, cp+m) - cp;
memset(bit, 0, sizeof(bit));
upd(pos(0), +1);
for(int i = 0; i<n; ++i){
if(qry(pos(qs[i] - L)) > qry(pos(qs[i] - R) - 1)){
if(qs[i]-R <= 0 && 0 <= qs[i]-L){
m = 0;
for(int j = 0; j<=i; ++j) I[m++] = A[j].S;
return m;
}
for(int j = 0; j<i; ++j){
if(qs[i]-R <= qs[j] && qs[j] <= qs[i]-L){
m = 0;
for(int k = j+1; k<=i; ++k) I[m++] = A[k].S;
return m;
}
}
}
upd(pos(qs[i]), +1);
}
return 0;
}
Compilation message
/usr/bin/ld: /tmp/ccSCKaeZ.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