# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
915017 | vjudge1 | Detecting Molecules (IOI16_molecules) | C++17 | 38 ms | 6484 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int n = w.size();
vector<int> ord(n);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int i, int j) { return w[i] < w[j]; });
vector<int64_t> pref(n + 1);
pref[0] = 0;
for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + w[ord[i]];
for (int i = 1; i <= n; i++) {
int64_t low = pref[i];
int64_t high = pref[n] - pref[n - i];
if (l <= low && low <= u) {
vector<int> ans;
for (int j = 0; j < i; j++) ans.push_back(ord[j]);
return ans;
}
if (l <= high && high <= u) {
vector<int> ans;
for (int j = n - i; j < n; j++) ans.push_back(ord[j]);
return ans;
}
if (high < l || u < low) continue;
vector<int> ans;
for (int j = 0; j < i; j++) ans.emplace_back(ord[j]);
int64_t cur = low;
for (int j = i - 1; j >= 0; j--) {
int le = i - 1, ri = n - 1 - (i - 1 - j);
if (cur + w[ord[ri]] - w[ord[j]] < l) {
cur += w[ord[ri]] - w[ord[j]];
ans[j] = ord[ri];
} else {
while (le <= ri) {
int mid = le + ri >> 1;
if (cur + w[ord[mid]] - w[ord[j]] > u) {
ri = mid - 1;
} else if (cur + w[ord[mid]] - w[ord[j]] < l) {
le = mid + 1;
} else {
cur -= w[ord[j]];
cur += w[ord[mid]];
assert(l <= cur && cur <= u);
ans[j] = ord[mid];
return ans;
}
}
}
}
}
return vector<int>();
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |