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>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair <ll,ll> pi;
typedef vector <int> vec;
int n;
pi a[200005];
ll L,R;
vec find_subset(int l,int r,vec w) {
L = l, R = r;
n = w.size();
for(int i = 0;i < n;i++) a[i].x = w[i], a[i].y = i;
queue <int> q;
ll sum = 0;
int i;
sort(a,a+n);
if(a[0].x > R) return {};
for(i = 0;i < n;i++) {
if(L <= sum+a[i].x&&sum+a[i].x <= R) {
vector <int> ans;
for(int j = 0;j <= i;j++) ans.push_back(a[j].y);
return ans;
}
if(sum+a[i].x < L) {
sum += a[i].x;
q.push(i);
}
else break;
}
for(int j = i;j < n;j++) {
int x = q.front(); q.pop();
sum -= a[x].x;
sum += a[j].x;
q.push(j);
if(L <= sum&&sum <= R) {
vector <int> ans;
while(!q.empty()) {
ans.push_back(a[q.front()].y);
q.pop();
}
return ans;
}
if(sum > R) while(1);
}
return {};
}
# | 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... |