# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
651873 | alvinpiter | Detecting Molecules (IOI16_molecules) | C++17 | 56 ms | 8608 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
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<LL> prefixSum;
prefixSum.push_back(indexedWeights[0].first);
for (int i = 1; i < indexedWeights.size(); i++) {
prefixSum.push_back(indexedWeights[i].first + prefixSum.back());
}
for (int i = 0; i < indexedWeights.size(); i++) {
int lo = i, hi = indexedWeights.size() - 1, mid;
while (hi >= lo) {
mid = (lo + hi)/2;
LL sum = prefixSum[mid] - (i == 0 ? 0 : prefixSum[i - 1]);
if (sum < l) {
lo = mid + 1;
} else {
hi = mid - 1;
}
}
LL sum = prefixSum[lo] - (i == 0 ? 0 : prefixSum[i - 1]);
if (sum >= l && sum <= u) {
vector<int> result;
for (int j = i; j <= lo; j++) {
result.push_back(indexedWeights[j].second);
}
return result;
}
}
vector<int> result;
return result;
}
Compilation message (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... |