Submission #1003386

#TimeUsernameProblemLanguageResultExecution timeMemory
1003386toast12Detecting Molecules (IOI16_molecules)C++14
100 / 100
38 ms8140 KiB
#include "molecules.h" #include <vector> #include <algorithm> using namespace std; #define ll long long vector<int> find_subset(int l, int u, vector<int> w) { int n = (int)w.size(); vector<pair<ll, int>> a; for (int i = 0; i < n; i++) { a.push_back({w[i], i}); } sort(a.begin(), a.end()); int left = 0, right = 0; ll cur_sum = a[0].first; bool poss = false; while (right < n) { while (cur_sum < l && right < n) { right++; cur_sum += a[right].first; } while (cur_sum > u) { cur_sum -= a[left].first; left++; if (right <= left) { right = left; cur_sum = a[left].first; } } if (cur_sum >= l && cur_sum <= u) { poss = true; break; } } vector<int> answer(0); if (poss) { for (int i = left; i <= right; i++) { answer.push_back(a[i].second); } } return answer; }
#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...