제출 #362130

#제출 시각아이디문제언어결과실행 시간메모리
362130penguinhackerDetecting Molecules (IOI16_molecules)C++14
100 / 100
61 ms3564 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; if (cur <= r) { vector<int> d(ind); for (int i = 0; i < ind; ++i) d[i] = v[i].second; return d; } cur -= v[--ind].first; vector<int> d(ind); iota(d.begin(), d.end(), 0); for (int i = ind - 1; i >= 0 && cur < l; --i) { cur += v[n + i - ind].first - v[i].first; d[i] = n + i - ind; if (cur >= l) break; } if (cur < l) return {}; for (int& i : d) i = v[i].second; return d; } /*int main() { ios::sync_with_stdio(0); cin.tie(0); int l = 1, r = 1; vector<int> w = {1}; 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...