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
#include<bits/stdc++.h>
using namespace std;
// random
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// templates
template<class X, class Y>
bool maximize(X &x, const Y &y) {
if (y > x) {
x = y;
return (true);
} else return (false);
}
template<class X, class Y>
bool minimize(X &x, const Y &y) {
if (y < x) {
x = y;
return (true);
} else return (false);
}
// define
#define fi first
#define se second
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define eb emplace_back
#define upb upper_bound
#define lwb lower_bound
#define left VAN
#define right TAN
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).begin(),(a).end()
#define sort_and_unique(a) sort(all(a));(a).resize(unique(all(a))-a.begin())
// another define
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
// limit
const int oo = 2e9;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = (int)w.size();
vector<pli> a(n + 5);
for (int i = 1; i <= n; i++) {
a[i].fi = w[i - 1];
a[i].se = i - 1;
}
sort(a.begin() + 1, a.begin() + n + 1);
vector<ll> ps(n + 5, 0);
for (int i = 1; i <= n; i++)
ps[i] = ps[i - 1] + a[i].fi;
for (int k = 1; k <= n; k++) {
if (ps[k] <= u && ps[n] - ps[n - k] >= l) {
vector<bool> mark(n + 5, 0);
for (int i = 1; i <= k; i++)
mark[i] = true;
ll s = ps[k];
for (int i = 1; i <= min(k, n - k); i++) if (s < l) {
mark[n - i + 1] = true;
mark[i] = false;
s += a[n - i + 1].fi - a[i].fi;
}
vector<int> ret;
for (int i = 1; i <= n; i++) if (mark[i])
ret.push_back(a[i].se);
return(ret);
}
}
vector<int> ret;
return (ret);
}
# | 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... |