# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
909964 | stefanneagu | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
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 <bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int r, vector<int> w) {
#define int long long
vector<pair<int, int>> v;
int n = w.size(); v.push_back({0, 0});
for(int i = 1; i <= n; i ++) {
v.push_back({w[i - 1], i - 1});
}
sort(v.begin(), v.end());
int sum = 0;
for(int i = 1, j = 1; i <= n; i ++) {
sum += v[i].first;
while(sum > r) {
sum -= v[j].first;
j ++;
}
if(sum >= l) {
vector<int> ans;
for(int ind = j; ind <= i; ind ++) {
ans.push_back(v[ind].second);
}
return ans;
}
}
vector<int> am_belit_coaiele;
return am_belit_coaiele;
}