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 <deque>
#include <algorithm>
using namespace std;
using ll = long long;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int N = w.size();
vector<pair<int, int>> cp(N);
for(int i = 0; i < N; ++i) cp[i] = {w[i], i};
sort(cp.begin(), cp.end());
int i = 0;
ll sum = 0;
deque<ll> ans;
for(int j = 0; j < N; ++j) {
sum += cp[j].first; // prendi l'elemento
ans.push_back(cp[j].second);
// togli gli elementi sbagliati
while(sum > u) {
sum -= cp[i].first;
ans.pop_front();
i++;
}
if(sum >= l) {
vector<int> ret;
for(auto &x : ans) ret.push_back(x);
return ret;
}
}
// nessuna risposta
return vector<int>();
}
# | 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... |