# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
867171 | StefanL2005 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 348 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 <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;
#define ll long long
vector<int> find_subset(int l, int u, vector<int> w)
{
set<int> Set;
int n = w.size();
vector<int> result;
sort(w.begin(), w.end());
if(l < w[0])
return result;
if (l - u < w[n-1] - w[0])
return result;
ll sum = 0;
int i = 0;
for (i; i < n; i++)
{
if (sum + w[i] > l)
break;
sum+= w[i];
Set.insert(w[i]);
}
int dif = l - sum;
while (i < n && !(u <= sum && sum <= l))
{
auto poz = Set.lower_bound(w[i] - dif);
if (poz == Set.end())
break;
sum= sum - *poz + w[i];
Set.erase(poz);
Set.insert(w[i]);
i++;
}
if (u <= sum && sum <= l)
{
auto p = Set.begin();
for(i = 0; i < n; i++)
if (w[i] == *p)
{
result.push_back(i);
Set.erase(p);
p = Set.begin();
}
}
return result;
}
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... |