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>
#define f first
#define s second
#define loop(i, n) for (int i = 0; i < n; ++i)
#define read(a, n) loop($, n) cin >> a[$];
#define show(a, n) \
loop($, n) cout << a[$] << " "; \
cout << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
/* // SET WITH INDEXING
// Implements logarithmic find_by_order() and order_of_key()
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
*/
// RANDOM NUMBER GENERATOR
// rng() generates u.a.r. from [0, 2^32 - 1]
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int> find_subset(int l, int u, vector<int> w){
int n = w.size();
vector<int> s(n);
iota(s.begin(), s.end(), 0);
sort(s.begin(), s.end(), [&w](const int& i, const int& j){
return w[i] < w[j];
});
ll cur = 0; int a = 0, b = 0, c = n;
while(b < n && cur + w[s[b]] <= u){
cur += w[s[b++]];
}
while(a < b && b < c && cur < l){
cur += w[s[--c]] - w[s[a++]];
}
vector<int> sol(0);
if(cur >= l){
sol.resize(n - c + b - a);
int j = 0;
for(int i = a; i < b; ++i){
sol[j++] = s[i];
}
for(int i = c; i < n; ++i){
sol[j++] = s[i];
}
}
return sol;
}
# | 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... |