Submission #59802

#TimeUsernameProblemLanguageResultExecution timeMemory
59802KubalionzzaleDetecting Molecules (IOI16_molecules)C++14
100 / 100
94 ms30924 KiB
#include "molecules.h" #include <algorithm> #include <vector> std::vector<int> find_subset(int l, int u, std::vector<int> w) { std::vector<int> vec; long long int sum = 0; int n = w.size(); std::pair<int, int> a[200010]; for (int i = 0; i < n; ++i) { a[i].first = w[i]; a[i].second = i; } std::sort(a, a + n); int last = -1; for (int i = n - 1; i >= 0; --i) { sum += a[i].first; if (sum >= l) { last = i; break; } } if (last == -1) return vec; if (sum >= l && sum <= u) { for (int i = n - 1; i >= last; --i) { vec.push_back(a[i].second); } return vec; } for (int i = last - 1, j = 1; i >= 0; --i, ++j) { sum -= a[n - j].first; sum += a[i].first; if (sum <= u) { for (int k = i; k < n - j; ++k) { vec.push_back(a[k].second); } return vec; } } return vec; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...