# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
831286 | manhtuan22007 | Detecting Molecules (IOI16_molecules) | C++14 | 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.
#include "molecules.h"
#include <bits/stdc++.h>
#define int long long
#define ll long long
using namespace std;
vector<int> find_subset(int l , int u , vector<int> w){
int n = (int)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());
int sum = 0 , j = 0;
for(int i = 0 ; i < n ; i ++){
sum += a[i].first;
while(sum > u && j <= i){
sum -= a[j].first;
++j;
}
if(sum >= l){
vector<int> res;
for(int x = j ; x <= i ; x ++) res.push_back(a[x].second);
return res;
}
}
return {};
}
// int32_t main(){
// // vector<int> x = find_subset(10, 20, {15, 17, 16, 18});
// // for(int i : x) cout << i << " ";
// }