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;
#define pb push_back
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int,int>> arr(n);
for(int i = 0; i < n; i++) {
arr[i] = make_pair(w[i],i);
}
sort(arr.begin(),arr.end());
vector<long long> pref(n+1);
for(int i = 1; i <= n; i++) {
pref[i] = pref[i-1]+arr[i-1].first;
// cout <<i << " " << pref[i] << endl;
}
// cout<<endl;
vector<int>ans;
int left = 1, right = n;
while(left<=right) {
long long x = pref[right]-pref[left-1];
// cout << left << " " << right << " " << x << endl;
if(x >= l && x <= u) {
for(int i = left-1; i < right; i++) {
ans.pb(arr[i].second);
}
break;
}
if(x > l) {
left++;
}
else {
right--;
}
}
sort(ans.begin(),ans.end());
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... |