# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
651834 | alvinpiter | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 212 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) {
vector<pair<int, int> > indexedWeights;
for (int i = 0; i < w.size(); i++) {
indexedWeights.push_back({w[i], i});
}
sort(indexedWeights.begin(), indexedWeights.end());
vector<int> result;
// Check if the lightest molecule is larger than u
if (indexedWeights[0].first > u) {
return result;
}
// Check if there is a molecule with weight between l and u
for (auto [weight, index]: indexedWeights) {
if (weight >= l && weight <= u) {
result.push_back(index);
return result;
}
}
// All molecules has weight < l
long long int totalWeight = 0;
for (int i = indexedWeights.size() - 1; i >= 0; i--) {
auto [weight, index] = indexedWeights[i];
totalWeight += weight;
result.push_back(index);
if (totalWeight >= l && totalWeight <= u) {
return result;
}
if (totalWeight > u) {
result.clear();
return result;
}
int lo = 0, hi = i - 1, mid;
while (hi >= lo) {
mid = (lo + hi)/2;
if (totalWeight + indexedWeights[mid].first < l) {
lo = mid + 1;
} else {
hi = mid - 1;
}
}
if (lo < i) {
if (totalWeight + indexedWeights[lo].first <= u) {
result.push_back(indexedWeights[lo].second);
return result;
}
}
}
return result;
}
컴파일 시 표준 에러 (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... |