| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1244966 | hmms127 | Detecting Molecules (IOI16_molecules) | C++20 | 0 ms | 0 KiB | 
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MN = 1e4+5;
const int MV = 1e4+5;
int dp[MV];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n=w.size();
    
    vector<array<int,2>> v;
    for(int i=0;i<n;i++){
        v.push_back({w[i],i});
    }
    sort(v.begin(),v.end());
    int r=0;long long sm=0;
    f1(n){
        while(r<n&&sm+v[r][0]<=u)sm+=v[r++][0];
        
        if(sm>=l){
            vector<int>ans;
            for(int j=i;j<r;j++)ans.push_back(v[j][1]);
            return ans;
        }
        
        sm-=a[i];
    }
    return {};
}
