#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;
#define endl "\n"
#define pb push_back
// #define int long long
#define fi first
#define se second
const int N = 3e5 + 5, M = 1e9 + 7, LG = 20;
int n;
vector<int> find_subset(int l, int u, vector<int> w1) {
vector<pair<int,int>> w;
for (int i=0; i<w1.size() ; i++){
w.pb({w1[i],i});
}
int su = 0 , ls = w.size()-1;
// cout << ls << endl;
vector<int> ans;
sort(w.rbegin(),w.rend());
for (int i=0 ; i <w.size() ; i++){
su += w[i].fi;
ans.pb(w[i].se);
if (l <= su && su <= u){
sort(ans.begin(),ans.end());
return ans;
}
if (su > u){
int f = i+1;
while(f--){
su -= w[i].fi;
ans.pop_back();
su += w[ls].fi;
ans.pb(w[ls].se);
i--;
ls--;
if (l <= su && su <= u){
sort(ans.begin(),ans.end());
return ans;
}
}
return vector<int>(0);
}
}
return vector<int>(0);
}
Compilation message (stderr)
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |