# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
394522 | idk321 | Detecting Molecules (IOI16_molecules) | C++11 | 1 ms | 272 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;
typedef long long ll;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
ll lsum = 0;
ll rsum = 0;
vector<int> res;
sort(w.begin(), w.end());
for (int i = 0; i < w.size(); i++)
{
lsum += w[i];
rsum += w[w.size() - 1 - i];
if (lsum <= u && rsum >= l)
{
int a = 0;
int b = a + i;
while (res.size() < i + 1)
{
while (b + 1 < w.size() && lsum - w[a] + w[b + 1] <= u)
{
lsum = lsum - w[a] + w[b + 1];
a++;
b++;
}
res.push_back(a);
a++;
}
break;
}
}
return res;
}
/*
7
15 16
5 5 5 5 6 6 6
*/
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... |