# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281894 | A02 | Detecting Molecules (IOI16_molecules) | C++14 | 146 ms | 13672 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) {
vector<pair<int, int> > w2;
for (int i = 0; i < w.size(); i++){
w2.push_back(make_pair(w[i], i));
}
sort(w2.begin(), w2.end());
long long total = 0;
set<int> result;
int i = 0;
for (; (i < w2.size()) && (total + w2[i].first <= u); i++){
total += w2[i].first;
result.insert(w2[i].second);
}
int result_size = i;
long long max_total = 0;
for (int j = w2.size() - 1; j >= (int) w2.size() - result_size; j--){
max_total += w2[j].first;
}
if (max_total < l){
return vector<int> ();
}
int current_lower_max = i - 1;
while (total < l){
result.erase(w2[current_lower_max].second);
result.insert(w2[w2.size() - 1 - (i - 1 - current_lower_max)].second);
total += w2[w.size() - 1 - (i - 1 - current_lower_max)].first;
total -= w2[current_lower_max].first;
current_lower_max--;
}
vector<int> r;
for (set<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... |