Submission #536455

#TimeUsernameProblemLanguageResultExecution timeMemory
536455timreizinDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms240 KiB
#include "molecules.h" #include <algorithm> #include <map> using namespace std; using ll = long long; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<ll, int>> a(n); for (int i = 0; i < n; ++i) a[i] = {w[i], i}; sort(a.begin(), a.end()); ll sum = 0; map<ll, int> prefs; prefs[0] = 0; for (int i = 0; i < n; ++i) { sum += a[i].first; auto it = prefs.lower_bound(sum - u); if (it != prefs.end()) { if (it->first <= sum - l) { vector<int> res; for (int j = it->second; j <= i; ++j) res.push_back(j); return res; } } prefs[sum] = i + 1; } 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...