# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
419282 | Mohammed_Atalah | Detecting Molecules (IOI16_molecules) | C++17 | 57 ms | 4548 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;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
std::vector< pair <int, int> > nums;
for (int i = 0; i < w.size(); i++) {
if (w[i] >= l && w[i] <= u) {
std::vector<int> p;
p.push_back(i);
return p;
} else if (w[i] > u) {
continue;
}
nums.push_back(make_pair(w[i], i));
}
if (nums.size() == 0) {
std::vector<int> v;
return v;
}
sort(nums.begin(), nums.end());
bool there = false;
int len = nums.size();
int left = 0; int right = 0;
long long total = nums[0].first;
while (left < len && right < len) {
if (total <= u && total >= l) {
there = true;
break;
} else if (total < l) {
right++;
if (right < len) {
total += nums[right].first;
}
} else if (total > u) {
total -= nums[left].first;
left++;
}
}
if (there == true) {
std::vector<int> res;
for (int i = left; i < right + 1; i++) {
res.push_back(nums[i].second);
}
return res;
}
std::vector<int> v;
return v;
}
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... |