# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1072291 | 2024-08-23T16:29:55 Z | ivaziva | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "molecules.h" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<int,int>> vec; vec.push_back({0,0}); int n=w.size(); for (int i=0;i<n;i++) vec.push_back({w[i],i}); sort(vec.begin(),vec.end()); int l=1,r=1,val=vec[1].first; bool resenje=false; while (l<=r) { if (val>=l and val<=u) {resenje=true;break;} if (val<l and r<n) {r++;val+=vec[r].first;} else if (val<l and r==n) break; else if (val>u and l<r) {val-=vec[l].first;l++;} else if (val>u and l==r) break; } vector<int> ans; if (!resenje) return ans; for (int i=l;i<=r;i++) ans.push_back(vec[i].second); return ans; }