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>
#ifndef _DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include "molecules.h"
#endif
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w)
{
int n = w.size();
vector<pair<int, int>> a(n);
for (int i = 0; i < n; i++)
a[i] = {w[i], i};
sort(a.begin(), a.end());
if (a[0].first > u)
return {};
if (a.back().first >= l && a.back().first <= u)
return {n - 1};
if (a[0].first >= l && a[0].first <= u)
return {0};
int i = 0;
int sum = 0;
for (int j = 0; j < n; j++)
{
sum += a[j].first;
while (sum > u)
{
sum -= a[i].first;
i++;
}
if (sum >= l)
{
vector<int> out;
for (int k = i; k <= j; k++)
{
out.push_back(a[k].second);
}
return out;
}
}
return {};
}
#ifdef _DEBUG
signed main()
{
int n, l, u;
cin >> n >> l >> u;
vector<int> a(n);
for (int &x : a)
cin >> x;
for (int x : find_subset(l, u, a))
cout << x << " ";
}
#endif
# | 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... |