이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <vector>
#include <algorithm>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = (int)w.size();
vector<pair<int, int>> a;
for (int i = 0; i < n; i++) {
a.push_back({w[i], i});
}
sort(a.begin(), a.end());
int left = 0, right = 0;
int cur_sum = a[0].first;
bool poss = false;
while (right < n) {
while (cur_sum < l && right < n) {
right++;
cur_sum += a[right].first;
}
while (cur_sum > u) {
cur_sum -= a[left].first;
left++;
if (right <= left) {
right = left;
cur_sum = a[left].first;
}
}
if (cur_sum >= l && cur_sum <= u) {
poss = true;
break;
}
}
vector<int> answer(0);
if (poss) {
for (int i = left; i <= right; i++) {
answer.push_back(a[i].second);
}
}
return answer;
}
# | 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... |