# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680373 | Nahian9696 | Detecting Molecules (IOI16_molecules) | C++17 | 1 ms | 340 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 <bits/stdc++.h>
using namespace std;
#define f0(i, n) for(int i = 0; i < n; i++)
#define f1(i, n) for(int i = 1; i <= n; i++)
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vector<pair<int, int>> vp;
f0(i, w.size()) {
vp.push_back({w[i], i});
}
sort(vp.begin(), vp.end());
long long sum = 0, n = w.size();
vector<int> ans;
for (long long i = 0; i < w.size(); i++) {
if (sum + vp[i].first <= u) {
sum += vp[i].first;
ans.push_back(vp[i].second);
} else {
if(sum >= l) {
return ans;
} else {
int nn = ans.size();
f1(j, nn) {
sum -= vp[nn - j].first;
sum += vp[n - j].first;
ans[nn - j] = vp[n - j].second;
if(sum >= l && sum <= u) {
return ans;
}
}
return vector<int>();
}
break;
}
}
// 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... |