# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
54502 | 2018-07-03T18:28:06 Z | MoNsTeR_CuBe | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KB |
#include "molecules.h" #include <bits/stdc++.h> //#define int long long using namespace std; vector<int> find_subset(int l, int r, vector<int> w){ #define int long long int n = w.size(); vector< pair<int, int> > v(n); for(int i = 0; i < n; i++){ v[i] = make_pair(w[i],i); } sort(v.begin(), v.end()); vector<bool> taken(n, false); int left = 0, right = 0; int tot = 0; while(1){ while(right < n && tot < l){ tot+=v[right].first; taken[v[right].first] = true; right++; } while(left < n && tot > r){ tot-=v[left].first; taken[v[left].first] = false; left++; } if(tot >= l && tot <= r){ vector<int> ans(0); for(int i = 0; i < n; i++){ if(taken[i]) ans.push_back(i); } return ans; } if(left >= n || right >= n) break; } vector<int> ans(0); return ans; } /* signed main(){ int a, b, c; cin >> a >> b >> c; vector<int> v(0); for(int i = 0; i < a; i++){ int d; cin >> d; v.push_back(d); } v = find_subset(b,c,v); cout << v.size() << endl; for(int i = 0; i < v.size(); i++){ cout << v[i] << ' '; } cout << endl; }*/