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>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w){
int n = w.size();
vector<pair<int, int>> v(n);
vector<int> pf(n);
for(int i = 0;i<n;i++){
v[i].first = w[i];
v[i].second = i;
}
pf[0] = v[0].first;
sort(v.begin(), v.end());
for(int i = 1;i<n;i++)pf[i] = pf[i-1] + v[i].first;
map<int, int> pos;
for(int i = 0;i<n;i++){
pos[pf[i]] = i;
}
for(int i = 0;i<n;i++){
if(pf[i] < l)continue;
if(pf[i] >= l && pf[i] <= u){
vector<int> a(i+1);
for(int j = 0;j<=i;j++)a[j] = v[j].second;
return a;
}
int req = pf[i] - u;
auto itr = lower_bound(pf.begin(), pf.end(), req);
if(pf[i] - *itr >= l && pf[i] - *itr <= u){
vector<int> a(i - pos[*itr]);
for(int j = pos[*itr] + 1, k = 0; j <= i;j++,k++)a[k] = v[j].second;
return a;
}
}
return vector<int>{};
}
# | 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... |