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;
typedef int64_t ll;
typedef string str;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
vector <int> find_subset(int l, int r, vector <int> w) {
int n = sz(w);
set <int> st;
ll cur = 0;
pair <int, int> v[n];
for (int i = 0; i < n; i++) {
v[i] = {w[i], i};
}
sort(v, v + n);
int tl = 0, tr = 0;
while (tr < n) {
if (cur < l) {
cur += v[tr].F;
st.insert(v[tr].S);
tr++;
}
if (cur > r) {
cur -= v[tl].F;
st.erase(v[tl].S);
tl++;
}
if (cur >= l && cur <= r) {
break;
}
}
if (cur >= l && cur <= r) {
return vector <int> (all(st));
}
return {};
}
# | 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... |