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 "molecules.h"
#include<algorithm>
#include<iostream>
#include<vector>
#define DIM 200005
#define f first
#define s second
using namespace std;
static long long sf[DIM], ss[DIM];
static vector<int> sol;
static pair<int, int> v[DIM];
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size(), i, j, k = 0;
for(i = 1; i <= n; i++){
v[i] = make_pair(w[i - 1], i - 1);
}
sort(v + 1, v + n + 1);
for(i = 1; i <= n; i++){
sf[i] = sf[i - 1] + v[i].f;
}
for(i = n; i >= 1; i--){
ss[i] = ss[i + 1] + v[i].f;
}
for(i = 1; i <= n; i++){
if(sf[i] <= u && ss[n - i + 1] >= l){
k = i;
break;
}
}
if(k == 0){
return sol;
}
long long sum = 0;
for(i = 1; i <= k; i++){
sol.push_back(v[i].s);
sum += v[i].f;
}
i = 1;
j = n;
while(sum < l){
sum += v[j].f - v[i].f;
sol[i - 1] = v[j].s;
i++;
j--;
}
sort(sol.begin(), sol.end());
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... |