#include "molecules.h"
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a:b)
#define ll long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
using vi = vector<int>;
vector<int> find_subset(int l, int u, vector<int> w) {
int n=w.size();
vector<pii> a(n);
rep(i,0,n){
a[i].fi=w[i];
a[i].se=i;
}
sort(all(a));
reverse(all(a));
deque<int> ans;
vi aa;
ll x=0;
rep(i,0,n){
ans.pb(a[i].se);
x+=a[i].fi;
if(x<l) continue;
break;
}
if(x<l) return aa;
repa(e,ans) aa.pb(e);
if(x<=u) return aa;
reverse(all(ans));
while(n>ans.size() && x>u){
n--;
x-=w[ans.back()];
x+=a[n].fi;
ans.ppb();
ans.pf(a[n].se);
}
if(x>u) ans.clear();
aa.clear();
repa(e,ans) aa.pb(e);
return aa;
}
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... |