이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "molecules.h"
struct weights {
int wt;
int idx;
};
bool cmp(weights a, weights b) {
return (a.wt < b.wt);
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
int total_weight = 0, i = 0;
std::queue<int> indices;
std::vector<struct weights> wts(n);
for(int i = 0; i < n; i++)
wts[i] = {w[i], i};
std::sort(wts.begin(), wts.end(), cmp);
while(total_weight < l && i < n) {
total_weight += wts[i].wt;
indices.push(wts[i++].idx);
}
i = 0;
while(total_weight > u && i < n) {
total_weight -= wts[i++].wt;
indices.pop();
}
if(total_weight < l || total_weight > u) return std::vector<int>(); //no subarray found
std::vector<int> ans(indices.size());
i = 0;
while(!indices.empty()) {
ans[i++] = indices.front();
indices.pop();
}
return ans;
}
# | 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... |