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>
#include "molecules.h"
/// https://codeforces.com/blog/entry/52464
/// https://oj.uz/submission/715687
using namespace std;
vector<int> find_subset(int l, int r, vector<int>w){
int n = w.size();
vector<pair<int, int>>sorted(n);
for(int i = 0;i < n;++i){
sorted[i] = {w[i], i};
}
sort(sorted.begin(), sorted.end());
vector<int>ans;
int left = 0, right = 0;
long long sum = 0;
while(left <= right && right < n){
sum += sorted[right].first;
while(sum > r){
sum -= sorted[left].first;
left++;
}
if(sum >= l && sum <= r){
for(int i = left;i <= right;++i){
ans.push_back(sorted[i].second);
}
return ans;
}
right++;
}
return ans;
}
//
//int main()
//{
// int l, r, n;
// cin >> l >> r >> n;
// vector<int>v(n);
// for(int i = 0;i < n;++i)cin >> v[i];
// vector<int>ans = find_subset(l, r, v);
// for(int i : ans)cout << i << " ";
//}
# | 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... |