#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;
int find_subset(int d, int u, int w[], int n, int result[]){
vector<pair<ll,int>> w2(n);
FOR(i,n) w2[i].f = w[i];
FOR(i,n) w2[i].s = i+1;
sort(all(w2));
int l = 0, r = 0;
ll total = 0;
for(; l < n; l++){
if(r < l){
total = 0;
r = l;
}else if(l != 0) total -= w2[l-1].f;
for(; total+w2[r].f <= u; r++) total += w2[r].f;
if(total >= d) break;
}
if(l == r){
return 0;
}else{
FOR(i,r-l) result[i] = w2[l+i].s;
return r-l;
}
}
//void testf(){
// int n,l,u;
// cin >> n >> l >> u;
// int w[n]; FOR(i,n) cin >> w[i];
// int ans[n];
// int m = find_subset(l,u,w,n,ans);
// cout << m << "\n";
// FOR(i,m) cout << ans[i] << " ";
// cout << "\n";
//}
//
//int main()
//{
// ios_base::sync_with_stdio(0); cin.tie(0);
//// testf();
// return 0;
//}
Compilation message
/tmp/ccB39ymk.o: In function `main':
grader.cpp:(.text.startup+0x12b): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status