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 INIT ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
ll p[200010];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int> res;
ll n=w.size();
sort(w.begin(), w.end());
for(int i=1; i<=n ;i++){
p[i]=p[i-1]+w[i-1];
}
if( (p[n]>=l) && (p[n]<=u) ){
for(int i=0; i<n; i++){res.pb(i);}
return res;
}
if( (p[n]<l) || (p[1]>u) ){return res;}
int r=0;
for(int i=1; i<=n; i++){
if( (p[i]>=l) && (p[i]<=u) ){
for(int j=0; j<i; j++){res.pb(j);}
return res;
}
if( (p[i]>u) && (( ( (i%2)==0) && ( (p[i]-p[i/2])>=l ) )||( ( (i%2)==1 ) && ( (p[i]-p[((int)i/2)])>=l ) ) ) && (p[i/2]<u) ) {
r=i; break;
}
}
if(r==0){return res;}
int mid=r/2;
int cnt=0;
ll sum=p[mid];
while(sum<l){
cnt++;
sum-=w[cnt-1];
sum+=w[r-cnt];
}
for(int i=(cnt+1); i<=mid; i++){
res.pb(i-1);
}
for(int i=r-cnt+1; i<=r; i++){
res.pb(i-1);
}
return res;
}
# | 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... |