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>
#include "molecules.h"
#define ll long long
#define fi first
#define se second
using namespace std;
const int maxn = 2e5 + 10;
int n;
ll pref[maxn];
ll suf[maxn];
vector <pair<int, int> > w2;
vector<int> find_subset(int l, int u, vector<int> w) {
n = w.size();
for(int i = 0; i < n; i++){
w2.push_back({w[i], i});
}
sort(w2.begin(), w2.end());
pref[0] = w2[0].fi;
suf[n - 1] = w2[n - 1].fi;
for(int i = 1; i < n; i++){
pref[i] = pref[i - 1] + w2[i].fi;
}
for(int i = n - 2; i >= 0; i--){
suf[i] = suf[i + 1] +w2[i].fi;
}
vector <int> v;
for(int k = 1; k <= n; k++){
// cout << k << " " << pref[k - 1] << endl;
if(pref[k - 1] <= u && suf[n - k] >= l){
// cout << k << endl;
int sum = pref[k - 1];
int x = 0;
while(sum < l){
sum -= w2[x].fi;
sum += w2[n - x - 1].fi;
x++;
}
for(int i = x; i < k; i++) v.push_back(w2[i].se);
for(int i = n - x; i < n; i++) v.push_back(w2[i].se);
return v;
}
}
return v;
}
# | 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... |