Submission #611062

#TimeUsernameProblemLanguageResultExecution timeMemory
611062TemmieDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms212 KiB
#include <bits/stdc++.h> inline std::vector <int> make(const std::vector <std::pair <int, int>>& a, int l, int r) { std::vector <int> res; for (int i = l; i <= r; i++) { res.push_back(a[i].second); } return res; } std::vector <int> find_subset(int l, int u, std::vector <int> w) { int n = w.size(); std::vector <std::pair <int, int>> a(n); for (int i = 0; i < n; i++) { a[i] = { w[i], i }; } std::sort(a.begin(), a.end()); long long sum = 0; for (int i = 0; i < n; i++) { sum += a[i].first; if (sum >= l && sum <= u) { return make(a, 0, i); } if (sum > u) { for (int j = 0; j < i; j++) { sum -= a[j].first; if (sum >= l && sum <= u) { return make(a, j + 1, i); } } break; } } 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...