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>
#include <numeric>
using namespace std;
using ll = long long;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int i = 0;
int N = w.size();
ll sum = 0;
vector<int> ord(N);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int a, int b){return w[a] < w[b];});
deque<ll> ans;
for(int j = 0; j < N; ++j) {
sum += w[ord[j]]; // prendi l'elemento
ans.push_back(j);
// togli gli elementi sbagliati
while(sum > u) {
sum -= w[ord[i]];
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... |