This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
#define ll int
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>*/
template<class S,class T>
bool chmin(S &a,const T &b) {
return a>b?(a=b)==b:false;
}
template<class S,class T>
bool chmax(S &a,const T &b) {
return a<b?(a=b)==b:false;
}
vll find_subset(ll l, ll u, vll w) {
ll i,j;
ll n=w.sz;
ll sum=0;
vll v;
sort(all(w));
if(w[0]>u)return v;
ll x=n;
for(i=0;i<n;i++){
if(sum+w[i]<l)sum+=w[i];
else {
if(sum+w[i]<=u){
for(j=0;j<=i;j++){
v.pb(w[i]);
}
return v;
}
x=i;
break;
}
}
if(x==n)return v;
for(i=0;i<x;i++){
if(w[n-i-1]<x)return v;
sum-=w[i];
sum+=w[n-i-1];
if(sum>=l && sum<=u){
for(j=i+1;j<x;j++) v.pb(w[i]);
for(j=0;j<=i;j++) v.pb(w[n-i-1]);
return v;
}
}
}
Compilation message (stderr)
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type]
68 | }
| ^
# | 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... |