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>
#include "molecules.h"
#define ve vector
#define ll long long
#define fi first
#define se second
using namespace std;
vector<int> find_subset(int L, int u, vector<int> w) {
int n = w.size();
ve<pair<ll, ll> > v(n);
for(int i = 0; i < n; i++)
v[i] = {w[i], i + 1};
sort(v.begin(), v.end());
ve<ll> p(n + 1, 0);
for(int i = 1; i <= n; i++)
p[i] = p[i - 1] + v[i - 1].fi;
int l= 0, r = 0;
while(l <= n && r <= n){
ll sum = p[r] - p[l];
if(sum >= L && sum <= u){
ve<int> res;
for(int i = l; i < r; i++)
res.push_back(v[i].se);
return res;
}
else if(sum < L)
r++;
else l++;
}
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... |