# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
249810 | 2020-07-15T19:37:12 Z | hhh07 | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <utility> #include <set> #include <cmath> #include <climits> #include <cstring> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef pair<ll, ll> ii; vi find_subset(ll l, ll u, vi w){ vi result; ll n = w.size(); ii x[n]; for (ll i = 0; i < n; i++) x[i] = {w[i], i}; sort(x, x + n); ll s = 0, curr = 0; bool t = false; for (ll i = 0; i < n; i++){ w[i] = x[i].first; s += w[i]; curr = i; if (s >= l && s <= u){ for (ll j = 0; j <= i; j++) result.push_back(x[j].second); return result; } if (s >= l){ s -= w[i]; t = true; break; } } if (!t) return result; for (ll i = curr; i < n; i++){ w[i] = x[i].first; s += w[i] - w[i - curr]; if (s >= l && s <= u){ for (ll j = i - curr + 1; j <= i; j++) result.push_back(x[j].second); return result; } } return result; }