#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)
{
int n = w.size();
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 = count(w.begin(), w.end(), w1);;
if (w0 != w1)
{
int fl = 0, cntw0, cntw1;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
if (i + j <= n && (i <= w0_count) && (j <= w1_count) && in(i * w0 + j * w1, l, r))
{
fl = 1;
cntw0 = i;
cntw0 = j;
}
}
}
if (!fl)
{
return res;
}
for (int i = 0, j = 0; i < n && j < cntw0; ++i)
{
if (w[i] == w0)
{
++j;
res.push_back(i);
}
}
for (int i = 0, j = 0; i < n && j < cntw1; ++i)
{
if (w[i] == w1)
{
++j;
res.push_back(i);
}
}
return res;
}
else
{
int tot = 0;
for (int i = 0; i < (int)w.size(); ++i)
{
tot += w[i];
res.push_back(i);
if (in(tot, l, r))
{
return res;
}
}
res.clear();
return res;
}
}
컴파일 시 표준 에러 (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... |