제출 #362120

#제출 시각아이디문제언어결과실행 시간메모리
362120penguinhackerDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array vector<int> find_subset(int l, int r, vector<int> w) { int n = w.size(); vector<pair<int, int>> v(n); for (int i = 0; i < n; ++i) { v[i].first = w[i]; v[i].second = i; } sort(v.begin(), v.end()); if (accumulate(w.begin(), w.end(), 0ll) < l) return {}; ll cur = 0; int ind = 0; for (; cur < l; ++ind) { cur += v[ind].first; } assert(cur >= l); cur -= v[--ind].first; assert(cur < l); vector<int> d(ind); iota(d.begin(), d.end(), 0); for (int i = ind - 1; i >= 0; --i) { cur += v[n + i - ind].first - v[i].first; d[i] = n + i - ind; assert(cur <= r); if (cur >= l) break; } assert(cur <= r); if (cur < l) return {}; for (int& i : d) i = v[i].second; return d; /*for (int i = 0; i < ind; ++i) { res[i] = v[d[i]].second; } return ind;*/ } /*int main() { ios::sync_with_stdio(0); cin.tie(0); int l = 15, r = 17; vector<int> w = {6, 8, 8, 7}; vector<int> ans = find_subset(l, r, w); cout << ans.size() << "\n"; for (int i : ans) cout << i << " "; return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...