# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
792982 | prvocislo | 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.
#pragma once
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <vector>
typedef long long ll;
typedef long double ld;
using namespace std;
vector<int> find_subset(ll l, ll r, vector<int> w)
{
int n = w.size();
vector<pair<int, int> > a;
for (int i = 0; i < n; i++) a.push_back({ w[i], i });
sort(a.begin(), a.end());
vector<ll> pf(n + 1, 0);
for (int i = 0; i < n; i++) pf[i + 1] = pf[i] + a[i].first;
for (int k = 1; k <= n; k++) if (pf[k] <= r && pf[n] - pf[n - k] >= l)
{
for (int i = 0; i + k <= n; i++) if (l <= pf[i + k] - pf[i] && pf[i + k] - pf[i] <= r)
{
vector<int> id;
for (int j = i; j < i + k; j++) id.push_back(a[j].second + 1);
return id;
}
}
return {};
}