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 "bits/stdc++.h"
#include "molecules.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n, l, u;
vector<pair<int, int>> w;
vector<int> pre;
vector<int> find_subset(int L, int U, vector<int> W)
{
n = (int)W.size();
l = L;
u = U;
for(int i = 0; i<n; i++)
{
w.pb(mp(W[i], i));
}
sort(w.begin(), w.end());
pre.assign(n, 0);
pre[0] = w[0].fi;
for(int i = 1; i<n; i++)
pre[i] = pre[i-1] + w[i].fi;
bool flag = false;
vector<int> result(0);
for(int k = 0; k<n; k++)
{
if(w[k].fi>=l&&w[k].fi<=u)
{
result.pb(w[k].se);
flag = true;
break;
}
int sum = w[k].fi;
for(int i = k+1; i<n; i++)
{
for(int j = i; j<n; j++)
{
int temp = sum;
temp=pre[j]-pre[i-1];
if(temp>=l&&temp<=u)
{
result.pb(w[i].se);
for(int h = i+1; h<=j; h++)
result.pb(w[h].se);
flag = true;
break;
}
}
if(flag)
break;
}
if(flag)
break;
}
return result;
}
# | 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... |