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>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
#define all(x) x.begin(), x.end()
#define rep(i,a,b) for(int i = a; i < b; i++)
vi find_subset(int l, int u, vi wi) {
int N = (int)wi.size();
vpii w(N);
rep(n,0,N) w[n] = make_pair(wi[n], n);
sort(all(w));
long bot = 0;
long top = 0;
int K = 0;
for(int k = 0; k <= N; k++) {
K = k;
if(l <= bot && bot <= u) {
vi ans(0);
rep(i,0,k) ans.push_back(w[i].second);
return ans;
}
if(l <= top && top <= u) {
vi ans(0);
rep(i,0,k) ans.push_back(w[N-1-i].second);
return ans;
}
if(bot < l && u < top)
break;
if(k == N) return vi(0);
bot += w[k].first;
top += w[N-1-k].first;
}
int k2 = 0;
rep(k,0,K) {
k2++;
bot -= w[K-1-k].first;
bot += w[N-1-k].first;
if(bot >= l) break;
}
vi ans(0);
rep(i,0,K-k2) ans.push_back(w[i].second);
rep(i,N-k2,N) ans.push_back(w[i].second);
return ans;
}
# | 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... |