이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <deque>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
struct PT {
int x, i;
} c[200005];
inline bool cmp(const PT &a, const PT &b) {
return a.x < b.x;
}
vector<int> find_subset(int l, int u, vector<int> w) {
vector <int> ans = {};
for (auto &t : w) c[n] = { t, n }, n++;
sort(c, c + n, cmp);
ll s = 0;
int r = 0;
deque <int> con;
for (int i = 0; i < n; i++) {
if (s + c[i].x > u) break;
s += c[i].x;
r = i;
con.push_back(c[i].i);
}
if (r == n - 1 && s < l) return ans;
while (r <= n - 1 && s < l) {
s -= w[con.front()];
con.pop_front();
con.push_back(c[r + 1].i);
s += c[r + 1].x;
r++;
}
if (l <= s && s <= u) {
while (!con.empty()) ans.push_back(con.front()), con.pop_front();
}
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... |