| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1302115 | lunarecho | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 0 KiB |
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> find_subset(ll lower, ll upper, vector<ll> weights) {
int n = weights.size();
vector<pair<ll,int>> p(n);
for(int i=0;i<n;++i) {
p[i] = {weights[i], i};
}
sort(p.begin(), p.end());
bool f = false;
int l = 0, r = 0;
ll s = 0;
while(r < n) {
s += p[r].first;
while(s > upper) {
s -= p[l].first;
++l;
}
if(lower <= s && s <= upper) {
f = true;
break;
}
++r;
}
vector<int> ans;
for(int i=l;i<=r;++i) {
ans.push_back(p[i].second);
}
sort(ans.begin(), ans.end());
return ans;
}
