#include <stdio.h>
#include <math.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
#define long long long
#define fi first
#define se second
typedef pair<int,int> ii;
int n;
set<ii> st;
vector<int> ans;
vector<ii> vec;
vector<int> find_subset(int l, int u, vector<int> w)
{
n = w.size();
for(int i = 0; i < w.size(); i++)
vec.push_back({w[i], i+1});
sort(vec.begin(), vec.end());
long sum = 0;
st.insert({0, n});
for(int i = n-1; i >= 0; i--)
{
sum += vec[i].fi;
st.insert({sum, i});
}
auto it = st.lower_bound({l, -1});
if(it != st.end() && it->fi <= u)
{
// printf("%d\n", it->fi);
for(int i = it->se; i < n; i++)
ans.push_back(vec[i].se);
return ans;
}
return 0;
int pref = 0;
for(int i = 0; i < n; i++)
{
pref += vec[i].fi;
st.erase({sum, i});
it = st.lower_bound({l-pref, -1});
if(it != st.end() && it->fi+pref <= u)
{
// printf("%d %d\n", pref, it->fi);
for(int j = 0; j <= i; j++)
ans.push_back(vec[j].se);
for(int j = it->se; j < n; j++)
ans.push_back(vec[j].se);
return ans;
}
sum -= vec[i].fi;
}
return vector<int>(0);
}
Compilation message
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:32:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < w.size(); i++)
~~^~~~~~~~~~
molecules.cpp:53:9: error: could not convert '0' from 'int' to 'std::vector<int>'
return 0;
^