# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
281874 | 2020-08-23T15:09:52 Z | A02 | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 384 KB |
#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; if (i == 0){ return vector<int> (0); } long long max_total = 0; for (int j = w2.size() - 1; j >= w2.size() - result_size; j--){ max_total += w2[j].first; } if (max_total < l){ return vector<int> (0); } 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 - 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | OK (n = 12, answer = YES) |
2 | Correct | 1 ms | 384 KB | OK (n = 12, answer = YES) |
3 | Correct | 1 ms | 256 KB | OK (n = 12, answer = NO) |
4 | Correct | 0 ms | 256 KB | OK (n = 12, answer = NO) |
5 | Correct | 1 ms | 384 KB | OK (n = 12, answer = YES) |
6 | Incorrect | 1 ms | 288 KB | sum of weights should be in [306..310] but it is 404 |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 384 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |