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 <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#include "molecules.h"
using namespace std;
const int N = 2e5 + 5;
vector <pair <int,int> > a;
int p[N];
vector<int> find_subset(int L, int R, vector<int> w) {
int n = w.size();
for (int i = 0; i < n; i++)
a.pb({w[i],i});
sort(a.begin(),a.end());
for (int i= 0;i<n;i++){
p[i] = a[i].f;
if (i) p[i] += p[i - 1];
}
vector <int> ans; ans.clear();
for (int i =0;i<n;i++){
int l = i + 1,r = n - 1,res = i;
while (l <= r){
int mid = (l + r)>>1,sum = p[mid];
if (i) sum -= p[i - 1];
if (sum >= L){
res = mid;
r = mid - 1;
} else{
l = mid + 1;
}
}
int s = p[res];
if (i) s-= p[i - 1];
if (L <= s && s <= R){
for (int j = i; j <= res; j++)
ans.pb(a[j].s);
return ans;
}
}
return ans;
}
# | 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... |