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>
#define F first
#define S second
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int,int>> arr(n);
for(int i=0;i<n;i++)arr[i] = {w[i],i};
sort(arr.begin(),arr.end());
vector<int> pre(n+1,0);
for(int i=1;i<=n;i++)pre[i] = pre[i-1] + arr[i-1].F;
// for(int i=0;i<=n;i++)cerr << pre[i] << " ";
// cerr << endl;
// for(int i=0;i<n;i++)cerr << arr[i].F << " ";
// cerr << endl;
// for(int i=0;i<n;i++)cerr << arr[i].S << " ";
// cerr << endl;
int a = 0,b = 0;
while(b<=n && a<=n){
// cerr << a << " " << b << " " << (pre[b] - pre[a]) << endl;
if(pre[b] - pre[a] >= l && pre[b] - pre[a] <= u){
break;
}
else if(pre[b] - pre[a] < l)b++;
else a++;
}
if(b == n+1 || a == n+1 || pre[b]-pre[a] < l || pre[b] - pre[a] > u)return vector<int>();
vector<int> ans;
for(int i=a;i<b;i++)ans.push_back(arr[i].S);
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... |