This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Zadanie: Detecting Molecules
Autor: Tomasz Kwiatkowski
*/
#include <bits/stdc++.h>
#include "molecules.h"
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 7;
const int INF = 1e9 + 7;
vector<int> find_subset(int l, int u, vector<int> w) {
int n = w.size();
vector<pair<int, int>> molecules(n);
for (int i = 0; i < n; ++i)
molecules[i] = {w[i], i};
sort(molecules.begin(), molecules.end());
vector<int> ans;
int r = 0;
ll sum = 0;
for (int left = 0; left < n; ++left) {
while (r < n && sum + molecules[r].fi <= u) {
sum += molecules[r].fi;
if (l <= sum) {
for (int i = left; i <= r; ++i)
ans.pb(molecules[i].se);
return ans;
}
++r;
}
sum -= molecules[left].fi;
r = max(r, left + 1);
}
return ans;
}
# | 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... |