Submission #592798

#TimeUsernameProblemLanguageResultExecution timeMemory
592798MahtimursuDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms340 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<ll, int>> v; int n = w.size(); for (int i = 0; i < n; ++i) v.push_back({w[i], i}); sort(v.begin(), v.end()); ll cs = 0; for (int i = 0; i < n; ++i) { cs += v[i].first; if (cs > u) break; if (cs >= l) { vector<int> ans; for (int j = 0; j <= i; ++j) ans.push_back(v[j].second); return ans; } if (i != n - 1 && cs + (v[n - 1].first - v[0].first) < l) continue; int j = i; while (j >= 0) { ll got = cs + (v[n - 1].first - v[j].first); if (got >= l && got <= u) { break; } j--; } if (j != -1) { vector<int> ans; for (int k = 0; k <= i; ++k) { if (k == j) continue; ans.push_back(v[k].second); } ans.push_back(v[n - 1].second); return ans; } } return vector<int>(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...