# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133931 | stoyan_malinin | Detecting Molecules (IOI16_molecules) | C++14 | 822 ms | 504 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 "grader.cpp"
#include<random>
#include <algorithm>
using namespace std;
mt19937 rnd(6942069);
vector<int> find_subset(int l, int u, vector<int> w)
{
long long sum = 0;
for(int i = 0;i<w.size();i++)
{
sum += w[i];
}
int minValue = 1e9;
for(int i = 0;i<w.size();i++)
{
minValue = min(minValue, w[i]);
}
for(int i = 0;i<w.size();i++)
{
if(w[i]>=l && w[i]<=u)
{
return vector <int>{i};
}
}
if(sum<l) return vector <int>{};
if(u<minValue) return vector <int>{};
vector <int> answer;
vector <pair <int, int>> v;
for(int i = 0;i<w.size();i++)
{
if(w[i]<=u) v.push_back({w[i], i});
}
long long tries = 0;
while(true)
{
tries++;
if(tries*w.size()>3e7) break;
sum = 0;
shuffle(v.begin(), v.end(), rnd);
for(int i = 0;i<v.size();i++)
{
sum += v[i].first;
if(sum>=l && sum<=u)
{
for(int j = 0;j<=i;j++)
{
answer.push_back(v[j].second);
}
return answer;
}
if(sum>u)
{
break;
}
}
}
return vector<int>{};
}
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... |