# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281864 | A02 | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 384 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 <vector>
#include <iostream>
#include <set>
#include <algorithm>
#include <utility>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
sort(w.begin(), w.end());
long long total = 0;
multiset<int> result;
int i = 0;
for (; i < w.size() && total + w[i] <= u; i++){
total += w[i];
result.insert(w[i]);
}
int result_size = i;
long long max_total = 0;
for (int j = w.size() - 1; j >= w.size() - result_size; j--){
max_total += w[j];
}
if (max_total < l){
return vector<int> (0);
}
int current_lower_max = i - 1;
while (total < l){
result.erase(result.lower_bound(w[current_lower_max]));
result.insert(w[w.size() - 1 - (i - 1 - current_lower_max)]);
total += w[w.size() - 1 - (i - current_lower_max)];
total -= w[current_lower_max];
current_lower_max--;
}
vector<int> r;
for (multiset<int>::iterator it = result.begin(); it != result.end(); it++){
r.push_back(*(it));
}
return r;
}
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... |