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 <memory.h>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#define maxx 200005
using namespace std;
typedef long long ll;
struct data{
ll w;
int idx;
};
data p[maxx];
bool cmp(data a, data b){
return a.w < b.w;
}
std::vector<int> find_subset(int l, int u, std::vector<int> weight){
vector<int>res;
res.clear();
int n = weight.size();
for(int i = 0; i < n; i++){
p[i].w = 1LL * weight[i];
p[i].idx = i;
}
sort(p, p + n, cmp);
ll sum = 0;
int ptr1 = 0, ptr2 = 0;
while(ptr1 < n){
while(ptr2 < n && sum < 1LL * l){
sum += p[ptr2].w;
ptr2++;
}
if(sum >= 1LL * l && sum <= 1LL * u){
for(int i = ptr1; i < ptr2; i++){
res.push_back(p[i].idx);
}
return res;
}
else{
while(ptr1 < n && sum > 1LL * u){
sum -= p[ptr1].w;
ptr1++;
}
}
if(ptr2 == n && sum < 1LL * l)
break;
}
return res;
}
# | 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... |