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 <algorithm>
using namespace std;
vector<int> W;
int n;
vector<int> find_subset(int l, int u, vector<int> w)
{
W = w;
n = w.size();
int i, x;
vector<int> I(n);
for(i = 0; i < n; i++) I[i] = i;
sort(I.begin(), I.end(), [] (int x, int y)
{
return W[x] < W[y];
});
int sum = 0;
vector<int> empty_res;
vector<int> res;
if(w[I[0]] > u) return empty_res;
for(x = 0; x < n && sum < l; x++)
{
i = I[x];
sum += w[i];
res.push_back(i);
}
if(sum < l) return empty_res;
res.pop_back();
res.push_back(I[n-1]);
return res;
}
# | 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... |