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 <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int N = 200005;
int n;
pair<int, int> a[N];
ll p[N], s[N];
std::vector<int> find_subset(int L, int R, std::vector<int> w)
{
n = sz(w);
for (int i = 1; i <= n; ++i)
{
a[i].fi = w[i - 1];
a[i].se = i - 1;
}
sort(a + 1, a + n + 1);
for (int i = 1; i <= n; ++i)
p[i] = p[i - 1] + a[i].fi;
for (int i = n; i >= 1; --i)
s[i] = s[i + 1] + a[i].fi;
for (int i = 0; i <= n; ++i)
{
int l = i + 1, r = n + 1;
int u = -1;
while (l <= r)
{
int m = (l + r) / 2;
if (p[i] + s[m] >= L)
{
u = m;
l = m + 1;
}
else
r = m - 1;
}
if (u != -1)
{
if (p[i] + s[u] <= R)
{
vector<int> ans;
for (int j = 1; j <= i; ++j)
ans.push_back(a[j].se);
for (int j = u; j <= n; ++j)
ans.push_back(a[j].se);
return ans;
}
}
}
return {};
}
# | 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... |