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;
std::vector<int> find_subset(int L, int U, std::vector<int> w) {
int n = w.size();
std::vector<pair<int, int>> v(n);
for(int i = 0; i<n; i++)
{
v[i] = make_pair(w[i], i);
}
sort(v.begin(), v.end());
set<int> s;
int l = 0, r = 0, sum = 0;
while(r < n)
{
sum += v[r].first;
s.insert(v[r].second);
while(l <= r && sum > U)
{
sum -= v[l].first;
s.erase(v[l].second);
l++;
}
if(L <= sum && sum <= U)
{
vector<int> ans;
for(int i : s)ans.push_back(i);
return ans;
}
r++;
}
return std::vector<int>(0);
}
# | 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... |