Submission #160164

#TimeUsernameProblemLanguageResultExecution timeMemory
160164AlexPop28Detecting Molecules (IOI16_molecules)C++11
100 / 100
67 ms3064 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<int> order(n); iota(order.begin(), order.end(), 0); sort(order.begin(), order.end(), [&](int a, int b) { return w[a] < w[b]; }); int i = 0, j = 0; long long sum = 0LL; while (i < n && j < n) { while (j < n && (i >= j || sum < l)) { sum += w[order[j++]]; } while (i + 1 < j && sum > u) { sum -= w[order[i++]]; } if (i < j && l <= sum && sum <= u) { vector<int> ans; for (int p = i; p < j; ++p) { ans.emplace_back(order[p]); } return ans; } sum -= w[order[i++]]; } return vector<int>(); }
#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...