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;
typedef long long ll;
const int ukr = 2e5+10;
vector<pair<int,int>> ar;
vector<int> ans;
vector<int> find_subset(int l, int u, vector<int> w) {
int n;
n = w.size();
for(int i = 0; i < n; i++){
ar.push_back({w[i], i+1});
}
sort(ar.begin(), ar.end());
ll tot = 0;
int ki = 0, ka = 0;
while(ki < n){
while(ka < n && tot < l){
tot += ar[ka].first;
ka++;
}
//cout << ki << " " << ka << " " << tot << " " << ar[ki].first << "\n";
if(tot >= l && tot <= u){
for(int i = ki; i < ka; i++){
ans.push_back(ar[i].second);
}
return ans;
}
tot -= ar[ki].first;
ki++;
if(tot >= l && tot <= u){
for(int i = ki; i < ka; i++){
ans.push_back(ar[i].second);
}
return ans;
}
}
return ans;
}
/* int main() {
int n, l, u;
assert(3 == scanf("%d %d %d", &n, &l, &u));
std::vector<int> w(n);
for (int i = 0; i < n; i++)
assert(1 == scanf("%d", &w[i]));
std::vector<int> result = find_subset(l, u, w);
printf("%d\n", (int)result.size());
for (int i = 0; i < (int)result.size(); i++)
printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]);
} */
# | 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... |