# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
241161 | 2020-06-23T07:27:39 Z | crossing0ver | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KB |
#include<bits/stdc++.h> #define local1 using namespace std; const int N = 5e3+5; int x[N],a[N*N],f[N],n,m; int answer(int result[],deque<int> v) { for (int i = 0; i < v.size(); i++) { result[i] = v[i]; } return v.size(); } int find_subset(int l, int u, int w[], int n, int result[]) { sort(w,w+n); long long tot = 0; deque<int> v; if (w[0] > u) return 0; for (int i = 0; i < n; i++) { if (w[i] + tot < l) { tot+=w[i]; v.push_back(i); } } int in = v.back(); for (int i = in + 1; i < n; i++) { if (w[i] + tot >= l && w[i] + tot <= u) { v.push_back(i); return answer(result,v); } if (w[i] + tot > u) { tot -= w[v.front()]; v.pop_front(); tot += w[i]; v.push_back(i); } else { tot += w[i]; v.push_back(i); } } return 0; } #ifdef local main() { } #endif