This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
* Author : shora
*/
#include <bits/stdc++.h>
#define print(_v) for (auto &_ : _v) {cerr << _ << ' ';} cerr << endl;
#include "molecules.h"
using namespace std;
using ll = long long;
const int oo = 1e9;
struct P {
int x = 0, i = 0;
bool operator < (const P& p) {
return x < p.x;
}
};
vector<int> find_subset(int l, int u, vector<int> v) {
int n = v.size();
vector<P> a(n);
for (int i = 0; i < n; ++i)
a[i].x = v[i], a[i].i = i;
sort(a.begin(), a.end());
vector<int> res;
for (int i = 0, j = 0, sum = 0; i < n;) {
while (j < n && sum < l) {
sum += a[j].x; j++;
}
if (sum >= l && sum <= u) {
for (int k = i; k < j; ++k)
res.push_back(a[k].i);
return res;
}
sum -= a[i].x; i++;
}
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... |