Submission #380682

#TimeUsernameProblemLanguageResultExecution timeMemory
380682madlogicDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms384 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = (int) w.size(); for (int i = 0; i < n; i++) { if (w[i] >= l && w[i] <= u) { return {i}; } } vector<pair<int, int>> nums; for (int i = 0; i < n; i++) { if (w[i] <= u) { nums.emplace_back(w[i], i); } } sort(nums.begin(), nums.end()); int cur = 0; multiset<pair<int, int>> ms; for (auto& [x, y] : nums) { cur += x; ms.insert({x, y}); if (cur > u) { int remove = u - cur; auto lb = ms.lower_bound({remove, -1}); cur -= (*lb).first; ms.erase(lb); } } if (cur < l) { return {}; } vector<int> res; for (auto s : ms) { res.push_back(s.second); } return res; }
#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...