#include "molecules.h"
#include <bits/stdc++.h>
#define REP(v, i, j) for (int v = i; v != j; v++)
#define FORI(v) for (auto i : v)
#define FORJ(v) for (auto j : v)
#define OUT(v, a) \
FORI(v) \
cout << i << a;
#define OUTS(v, a, b) \
cout << v.size() << a; \
OUT(v, b)
#define in(a, n) \
REP(i, 0, n) \
cin >> a[i];
#define SORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define MEMSET(m) memset(m, -1, sizeof m)
#define pb push_back
#define fi first
#define se second
#define detachIO \
ios_base::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<pii, pii> piiii;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int> ans;
vector<pii> dj;
REP(i,0,w.size())dj.pb({w[i],i});
SORT(dj);
vector<int> vec;
int cur=0;
int s=0;
SORT(w);
REP(i,0,w.size()){
cur+=w[i];
vec.pb(cur);
if(cur<=u)s=i+1;
// cerr<<i<<" -> "<<cur<<'\n';
}
// cerr<<"s = "<<s<<endl;
if(s==0)return {};
cur=0;
REP(i,0,s){
cur+=w[w.size()-1-i];
}
if(cur<l)return {};
REP(i,0,w.size()){
if((i+s)>w.size())break;
int sum=vec[i+s-1];
if(i)sum-=vec[i-1];
// cerr<<i<<" - "<<(i+s)<<": "<<sum<<endl;
if(l<=sum && sum<=u){
REP(j,i,i+s){
ans.pb(dj[j].se);
}
return ans;
}
}
return {};
}
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... |