# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
159419 | 2019-10-22T16:19:13 Z | Mounir | Detecting Molecules (IOI16_molecules) | C++14 | 0 ms | 0 KB |
#include <bits/stdc++.h> #define int long long using namespace std; struct Molecule { int val, id; bool operator < (const Molecule &autre) const { return val < autre.val; } }; vector<int> resoudre(int borneMin, int borneMax, vector<int> poid) { vector<Molecule> poids; for (int i = 0; i < (int)poid.size();++i) poids.push_back({poid[i], i}); int ptEnd = 0, sumCur = 0; for (int ptStart = 0; ptStart < (int)poids.size(); ++ptStart) { for (; ptEnd < (int)poids.size() && sumCur < borneMin; ++ptEnd) sumCur += poids[ptEnd].val; if (sumCur >= borneMin && sumCur <= borneMax) { vector<int> res; for (int id = ptStart; id < ptEnd; ++id) res.push_back(poids[id].id); return res; } sumCur -= poids[ptStart].val; } return {}; } vector<int> find_subset(int l, int u, vector<int> w) { return resoudre(l, u, w); }