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 <vector>
#include <bitset>
const int DIM = 30 * 8388608; ///2^23
std::bitset <DIM> s;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
std::vector <int> ans;
s[0] = 1;
for(auto it : w)
s |= (s << it);
int p = -1;
for(int pos = l; pos <= u; pos++)
if(s[pos] == 1)
{
p = pos;
break;
}
if(p == -1)
return ans;
int pointerW = (int)w.size() - 1;
while(p > 0)
{
while(pointerW >=0 && (p - w[pointerW] < 0 || s[p - w[pointerW]] != 1))
pointerW--;
if(pointerW >= 0) {
ans.push_back(pointerW);
p -= w[pointerW];
pointerW--;
}
}
return ans;
}
# | 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... |