# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
810647 | wortelworm | Detecting Molecules (IOI16_molecules) | C++17 | 1069 ms | 2260 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 "grader.cpp"
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
std::vector<int> find_subset(int lower, int upper, std::vector<int> w) {
// sum -> last weight index
vector<int> sums(lower, -1);
sums[0] = 0;
for (int j = 0; j < w.size(); j++) {
for (int i = lower - 1; i >= 0; i--)
{
if (sums[i] == -1) {
continue;
}
int total_weight = w[j] + i;
if (total_weight >= lower && total_weight <= upper) {
// Done!
// indexes of weights
vector<int> result;
int current_weight = total_weight;
int current_index = j;
while (current_weight != 0) {
result.push_back(current_index);
current_weight -= w[current_index];
current_index = sums[current_weight];
}
return result;
}
if (sums[total_weight] != -1) {
// already found
continue;
}
sums[total_weight] = j;
}
}
return {};
}
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... |