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 <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 10;
const int INF = 1e9 + 10;
vector <int> find_subset(int l, int u, vector <int> w) {
int n = (int)w.size();
vector <pair<int, int>> esim;
vector <ll> pref;
for (int i = 0; i < n; i++) {
esim.push_back({ w[i], i });
}
sort(esim.begin(), esim.end());
ll s = 0;
for (auto &it : esim) {
s += it.first;
pref.push_back(s);
}
for (int i = 0; i < n; i++) {
ll w = 0;
if (i) w = pref[i - 1];
int ind = lower_bound(pref.begin(), pref.end(), w + l) - pref.begin();
if (ind == n) continue;
if ((pref[ind] - w) <= u) {
vector <int> v;
for (int j = i; j <= ind; j++) {
v.push_back(esim[j].second);
}
return v;
}
}
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... |