# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069541 | 2024-08-22T05:16:16 Z | Ignut | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KB |
// Ignut #include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> solve(int L, int U, vector<int> w) { int n = w.size(); vector<pair<int, int>> v; for (int i = 0; i < n; i ++) v.push_back({w[i], i}); sort(v.begin(), v.end()); for (int l = 0; l < n; l ++) { ll sum = 0; for (int r = l; r < n; r ++) { sum += v[r].first; if (sum > U) break; if (sum < L) continue; vector<int> res; for (int i = l; i <= r; i ++) res.push_back(v[i].second); return res; } } return {}; }