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 <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> v2i;
typedef pair<int, int> pi;
typedef vector<pi> vpi;
#define pb push_back
#define mp make_pair
#define rept(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
vpi ms;
int n = w.size();
rep(i, n) ms.pb({ w[i], i });
sort(ms.begin(), ms.end());
ll s = 0;
queue<pi> q;
bool found = true;
for (int i = 0; i < n && (s < l || s > u);) {
if (s < l) {
q.push(ms[i]);
s += ms[i].first;
i++;
}
else {
s -= q.front().first;
q.pop();
}
if (i >= n) found = false;
}
vi res;
res.reserve(n);
if (!found && (s < l || s > u)) return res;
while (!q.empty()) {
res.pb(q.front().second);
q.pop();
}
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... |