이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
#define ff first
#define ss second
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector <pair <int, int> > nums;
for (int i = 0; i < n; i++) {
nums.push_back({w[i], i});
}
sort(nums.begin(), nums.end());
queue <pair <int, int> > cur; // val, idx
vector <int> ans;
ll sum = 0, pos = 0;
bool answ = 0;
while(pos < n) {
sum += nums[pos].ff;
cur.push({nums[pos++]});
if (l <= sum && sum <= u) {
answ = 1;
break;
}
while(sum > u) {
auto num = cur.front();
cur.pop();
sum -= num.ff;
}
if (l <= sum && sum <= u) {
answ = 1;
break;
}
}
if(answ) {
while(!cur.empty()) {
ans.push_back(cur.front().ss);
cur.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... |