# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
939478 | ifateen | Detecting Molecules (IOI16_molecules) | C++14 | 1 ms | 600 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 <bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<int> ans;
vector<long long> pref(w.size());
vector<pair<int, int>> arr(w.size());
for (size_t i = 0; i < w.size(); i++) {
arr[i] = {w[i], i};
}
sort(begin(arr), end(arr));
int len = -1;
pref[0] = arr[0].first;
for (size_t i = 1; i < w.size(); i++) pref[i] = pref[i - 1] + arr[i].first;
for (size_t i = 0; i < w.size(); i++)
if (pref[i] > u) {
len = i;
break;
}
if (len == -1) {
ans.resize(w.size());
iota(begin(ans), end(ans), 0);
return ans;
}
for (size_t i = 0; i <= w.size() - len; i++)
if (l <= pref[i + len] - pref[i] && pref[i + len] - pref[i] <= u) {
for (size_t j = i + 1; j <= i + len; j++) ans.push_back(arr[j].second);
return ans;
}
if (l <= pref[len - 1] && pref[len - 1] <= u) {
for (size_t j = 0; j < len; j++) ans.push_back(arr[j].second);
}
return ans;
}
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... |