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 int ll
#define pii pair <int, int >
#define f first
#define s second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#endif // BALBIT
#define pb push_back
#define REP(i,n) for (int i = 0; i<(n); ++i)
#define REP1(i,n) for (int i = 1; i<=(n); ++i)
std::vector<signed> find_subset(signed l, signed u, std::vector<signed> w) {
vector <int> id;
int n = SZ(w);
REP(i,n) id.pb(i);
sort(ALL(id), [&](int a, int b){return w[a] < w[b];});
int j = -1;
ll s = 0;
for (int i = 0; i<n; ++i) {
while (s < l) {
if (j+1 == n) return {};
++j;
s += w[id[j]];
}
if (s >= l && s <= u) {
vector<signed> ret;
for (int k = i; k<=j; ++k) {
ret.pb(id[k]);
}
return ret;
}
s -= w[id[i]];
}
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... |