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>
using namespace std;
#define ll int
#define F first
#define S second
#define pb push_back
#define sz(x) (ll)x.size()
typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
#define ins insert
ll s;
set <ll> st;
vi c;
void add(ll idx){
st.ins(idx);
s += c[idx];
}
void rem(ll idx){
st.erase(idx);
s -= c[idx];
}
vi find_subset(int l, int r, vi cc) {
sort(cc.begin(),cc.end());
c = cc;
ll n = sz(c), p = 0; s = 0;
while (p < n && s < l){
add(p);
p++;
}
p--;
if (s < l){ //impossible to reach l
return vi();
}
if (s > r){
rem(p);
p--;
}
// dbg(p);
ll m = min(p, n-p-1);
p = 0;
// dbg2(s,m);
while (p <= m && s < l){
rem(p);
add(n-p-1);
p++;
}
if (s < l) return vi();
vi ans;
for (set <ll> :: iterator it = st.begin(); it != st.end(); it++){
ans.pb(*it);
}
return ans;
}
/*
4 15 17
6 8 8 7
*/
# | 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... |