제출 #485743

#제출 시각아이디문제언어결과실행 시간메모리
485743dongliu0426Detecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms296 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l0, int r0, vector<int> aa) { int n = (int) aa.size(); long long l1 = 0, r1 = 0; vector<int> ii(n); for (int i = 0; i < n; i++) ii[i] = i; sort(ii.begin(), ii.end(), [&](int i, int j) { return aa[i] < aa[j]; }); for (int k = 1; k <= n; k++) { l1 += aa[k - 1], r1 += aa[n - k]; if (l1 <= r0 && r1 >= l0) { vector<int> ans; long long sum = 0; for (int i = 0; i < k; i++) ans.push_back(ii[i]), sum += aa[ii[i]]; for (int i = 0; i < k && sum < l0; i++) ans[i] = ii[n - i - 1], sum += aa[ans[i]] - aa[ii[i]]; return ans; } } return {}; }
#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...