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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<ll, int>
#define F first
#define S second
const int N = 200005;
const int mod = 1e9+7;
bool cmp(pii a, pii b){
return a.F < b.F;
}
vector<int> find_subset(int l, int u, vector<int> w) {
pii a[N];
int n = 0;
for(int i : w){
a[n] = {i, n};
n++;
}
sort(a, a + n, cmp);
set<int> s;
vector<int> ans;
ll sum = 0, p1 = 0, p2 = 0;
while(p2 != n && p1 != n){
while(sum < l){
sum += a[p1].F;
s.insert(a[p1].S);
p1++;
if(p1 == n) break;
}
while(sum > u){
sum -= a[p2].F;
s.erase(s.find(a[p2].S));
p2++;
if(p2 == n) break;
}
if(sum >= l && sum <= u){
while(s.size() > 0){
ans.pb(*s.begin());
s.erase(s.begin());
}
break;
}
}
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... |