#include "molecules.h"
#include "bits/stdc++.h"
using namespace std;
bool in(const int &x, const int &lf, const int &rg)
{
return lf <= x && x <= rg;
}
vector<int> find_subset(int l, int r, vector<int> w)
{
vector<int> res;
int w0 = *min_element(w.begin(), w.end());
int w0_count = count(w.begin(), w.end(), w0);
int w1 = *max_element(w.begin(), w.end());
int w1_count = (int)w.size() - w0_count;
int i, j, fl = 0;
for (i = 0; i <= w0_count; ++i)
{
for (j = 0; j <= w1_count; ++j)
{
if (in(i*w0 + j*w1, l, r))
{
fl = 1;
break;
}
}
}
if (!fl)
{
return res;
}
array<int, 2> curr = {0,0};
for (int ind = 0; ind < (int)w.size(); ++ind)
{
if (w[ind] == w0 && curr[0] < i)
{
++curr[0];
res.push_back(ind);
}
if (w[ind] == w1 && curr[1] < j)
{
++curr[1];
res.push_back(ind);
}
}
return res;
}
Compilation message (stderr)
molecules.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | 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... |