Submission #362348

#TimeUsernameProblemLanguageResultExecution timeMemory
362348usuyusDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms364 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> find_subset(int l, int r, vector<int> a) { int n = a.size(); vector<pair<int,int>> b; for (int i=0; i<n; i++) b.push_back({a[i], i}); sort(a.begin(), a.end()); sort(b.begin(), b.end()); vector<ll> pre; pre.push_back(0); for (int x : a) pre.push_back(x + pre.back()); pre.push_back(1e18); for (int i=n; i>=0; i--) { ll sum = pre[n] - pre[i]; if (sum > r) break; int idx = lower_bound(pre.begin(), pre.end(), l - sum) - pre.begin(); idx = min(idx, i); if (pre[idx] + sum <= r) { vector<int> ans; for (int j=0; j<idx; j++) ans.push_back(b[j].second); for (int j=i; j<n; j++) ans.push_back(b[j].second); 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...