Submission #592803

#TimeUsernameProblemLanguageResultExecution timeMemory
592803MahtimursuDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms212 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; for (int j = i; j >= 0; --j) { for (int k = i + 1; k < n; ++k) { ll got = cs + (v[k].first - v[j].first); if (got >= l && got <= u) { vector<int> ans; for (int a = 0; a <= i; ++a) { if (j == a) continue; ans.push_back(v[a].second); } ans.push_back(v[k].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...