# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
348976 | Iwanttobreakfree | 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 <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include "molecules.h"
using namespace std;
vector <int> find_subset(int l,int u,vector <int>& w ){
vector <int> res;
int suma,contador;
for(int a=0;a<w.size();a++){
if(w[a]<=u&&w[a]>=l){
res[0]=w[a];
return res;
}
else if(w[a]>u) w.erase(w.begin()+a);
}
sort(w.rbegin(),w.rend());
while (suma<l||suma>u){
if(suma<l) {
suma+=w[contador];
res[contador]=w[contador],contador++;
}
else if(suma>u) {
suma-=w[contador];
res.erase(res.begin()+contador),contador--;
}
}
return res;
}