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;
vector<int> find_subset(int l, int u, vector<int> w) {
vector<int> v;
int n = w.size();
typedef pair<long long, long long> ii;
ii arr[n];
for(int i = 0;i < n;i++){
arr[i] = ii(w[i],i);
}
sort(arr,arr+n);
long long low = 0;
long long high = 0;
vector<int> ll;
vector<int> hh;
for(int c = 0;c < n;c++){
low += arr[c].first;
high += arr[n-c-1].first;
ll.push_back(arr[c].second);
hh.push_back(arr[n-c-1].second);
if(l <= low && low <= u){
return ll;
}
else if(l <= high && high <= u){
return hh;
}
else if(low < l && high > u){
for(int i = 0;i <= c;i++){
long long x = ll[i];
long long y = hh[i];
low -= w[x];
low += w[y];
hh[i] = x;
ll[i] = y;
if(l <= low && low <= u){
return ll;
}
}
while(true){
}
}
}
return v;
}
# | 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... |