# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299371 | 2020-09-14T19:49:35 Z | APROHACK | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include "molecules.h" #include <bits/stdc++.h> #define PB push_back using namespace std; vector<int> find_subset(int l, int u, vector<long long> w) { vector<int>respuesta; //sort(w.begin(), w.end()); long long sum=0, n=w.size(); long long menor=w[0], mayor=w[n-1], nn=0, mm=0; set<int>menores, mayores; for(int i = 0 ; i < n ; i ++){ menor=min(menor, w[i]); mayor=max(mayor, w[i]); } for(int i = 0 ; i < n ; i ++){ if(w[i]==menor)nn++; else mm++; if(w[i]==menor)menores.insert(i); else mayores.insert(i); } //cout<<menor<<" "<<mayor; for(int i = 0 ; i <= nn ; i ++){ for(int j = 0 ; j <= mm ; j++){ if(i*menor+j*mayor>=l&&i*menor+j*mayor<=u){ long long cont=0; for(auto x:menores){ if(cont==nn)break; cont++; respuesta.push_back(x); //if(cont==nn)break; } cont=0; for(auto x:mayores){ if(cont==mm)break; cont++; respuesta.push_back(x); } return respuesta; } } } return respuesta; //return std::vector<int>respuesta; }