# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
959418 | Mystic03 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 856 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 <algorithm>
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
int p1 = 0;
int r = 0;
int n = w.size();
std::vector<pair<int, int>> ele;
for (int i = 0; i < n; i++) {
ele.push_back({ w[i], i });
}
sort(ele.begin(), ele.end());
int currSum = 0;
while (currSum < l) {
if (r == w.size()) return std::vector<int>(0);
currSum += ele[r].first;
r++;
}
vector<int> res;
if (currSum <= u) {
for (int i = 0; i < r; i++) {
res.push_back(ele[i].second);
}
return res;
}
r--;
currSum -= ele[r].first;
for (int i = r; i < w.size(); i++) {
currSum += ele[i].first;
currSum -= ele[p1++].first;
if (currSum >= l && currSum <= u) {
for (int i = p1; i <= i; i++) {
res.push_back(ele[i].second);
}
return res;
}
}
return std::vector<int>(0);
}
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... |