#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;
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;
}
}
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
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:67:1: warning: control reaches end of non-void function [-Wreturn-type]
67 | }
| ^
molecules.cpp:62:24: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
62 | for(j=i+1;j<x;j++) v.pb(w[i]);
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Integer 50 violates the range [0, 11] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |