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 <molecules.h>
#include <bits/stdc++.h>
using namespace std;
vector<int> find_subset(int ll, int uu, vector<int> ww) {
long long n = ww.size(),l=ll,u=uu;
vector<pair<long long,long long>>w(n);
for(long long i = 0 ; i < n ; i++) {
w[i].first=ww[i],w[i].second=i;
}
long long cnt=0;
sort(w.begin(),w.end());
long long left=0,right=0;
while(right < n) {
if(cnt + w[right].first > u) break;
cnt+=w[right].first;
right++;
}
if(right == 0) return {};
bool f=false;
while(right <= n) {
if(cnt >= l && cnt <= u) {
f=true; break;
}
if(right == n) break;
cnt+=w[right].first;
cnt-=w[left].first;
right++,left++;
}
vector<int>ans={};
if(f) {
for(; left < right ; left++) ans.push_back(w[left].second);
}
return ans;
}
/*signed main() {
long long n,l,u;
cin >> n >> l >> u;
vector<long long>w(n);
for(auto &z : w)
cin >> z;
vector<long long>v = find_subset(l,u,w);
for(auto x : v)
cout << x << " ";
}*/
# | 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... |