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;
long long sum, n, kezd=-1, veg;
vector<pair<long long, int> >sz;
vector<int> ans;
void add(int a, int b) {
sum+=b*sz[a].first;
}
vector<int> find_subset(int a, int b, vector<int> w) {
n=w.size(), veg=n;
for (int i=0; i<n; i++) {
sz.push_back({w[i], i});
}
sort(sz.rbegin(), sz.rend());
while(kezd+1<n && sum<a) {
kezd++;
add(kezd, 1);
}
if (a<=sum && sum<=b) {
for (int i=0; i<=kezd; i++) ans.push_back(sz[i].second);
return ans;
}
while(kezd>=0 && sum>b) {
add(kezd, -1), kezd--;
veg--, add(veg, 1);
if (a<=sum && sum<=b) {
for (int i=0; i<=kezd; i++) ans.push_back(sz[i].second);
for (int i=veg; i<n; i++) ans.push_back(sz[i].second);
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... |