# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
72935 | 2018-08-27T09:10:52 Z | FedericoS | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include <algorithm> #include "molecules.h" using namespace std; typedef long long int ll; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<ll> V; ll N=w.size(); ll S=0; vector<pair<ll,ll>> W; for(ll i=0;i<N;i++) W.push_back({w[i],i}); sort(W.begin(), W.end()); for(ll a=0,b=0;a<N;a++){ S-=a?W[a-1].first:0; while(l>S and b<N) S+=W[b++].first; if(l<=S and S<=u){ for(ll i=a;i<b;i++) V.push_back(W[i].second); return V; } } return V; }