#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define foru(i,a,b) for(int i=(a); i<=(b); ++i)
#define ford(i,a,b) for(int i=(a); i>=(b); --i)
#define rep(i,a) for(int i=0; i<(a); ++i)
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define bit(s,i) (((s)>>(i))&1)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define fi first
#define se second
#define ll long long
#define eb emplace_back
#define pb push_back
#define __builtin_popcount __builtin_popcountll
#define _ << " " <<
template <class X, class Y> bool maxi(X &x, Y y){return x<y?x=y,true:false;}
template <class X, class Y> bool mini(X &x, Y y){return x>y?x=y,true:false;}
vi find_subset(int l, int u, vi w) {
vii wi;
rep(i,sz(w)) wi.eb(w[i],i);
sort(all(wi));
ll tot=0;
for(int i:w) tot+=i;
if(tot<l) return vi(0);
if(wi[0].fi>u) return vi(0);
if(wi[0].fi>=l&&wi[0].fi<=u) return vi(1,wi[0].se);
int i=0, j=-1; tot=0;
while(true){
if(j+1==sz(wi) || tot+wi[j+1].fi>=l){
break;
}
tot+=wi[j+1].fi;
++j;
}
if(tot+wi[j+1].fi>=l && tot+wi[j+1].fi<=u){
vi res;
foru(k,0,j+1) res.eb(wi[k].se);
return res;
}
while(tot<l && j<sz(wi)-1){
tot+=wi[j+1].fi-wi[i].fi;
++j; ++i;
}
if(tot<l) return vi(0);
vi res;
foru(k,i,j) res.eb(wi[k].se);
return res;
}
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... |