#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;
pll w;
for(i=0;i<n;i++)w.pb({W[i],i});
sort(all(w));
if(w[0].fr>u)return v;
ll x=n;
for(i=0;i<n;i++){
if(sum+w[i].fr<l)sum+=w[i].fr;
else {
if(sum+w[i].fr<=u){
for(j=0;j<=i;j++){
v.pb(w[i].sc);
}
return v;
}
x=i;
break;
}
}
if(x==n)return v;
for(i=0;i<x;i++){
if(w[n-i-1].fr<x)return v;
sum-=w[i].fr;
sum+=w[n-i-1].fr;
if(sum>=l && sum<=u){
for(j=i+1;j<x;j++) v.pb(w[j].sc);
for(j=0;j<=i;j++) v.pb(w[n-j-1].sc);
return v;
}
}
return {};
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
0 ms |
348 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
344 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
0 ms |
348 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
0 ms |
348 KB |
item #5 is taken twice |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
0 ms |
348 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
0 ms |
348 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
0 ms |
348 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
0 ms |
348 KB |
OK (n = 1, answer = NO) |
3 |
Correct |
1 ms |
348 KB |
OK (n = 1, answer = YES) |
4 |
Incorrect |
0 ms |
348 KB |
item #1 is taken twice |
5 |
Halted |
0 ms |
0 KB |
- |