Submission #28946

#TimeUsernameProblemLanguageResultExecution timeMemory
28946h0ngjun7Detecting Molecules (IOI16_molecules)C++14
31 / 100
3 ms3652 KiB
#include "molecules.h" #include <algorithm> using namespace std; typedef long long ll; int n; struct PT { int x, i; } c[200005]; inline bool cmp(const PT &a, const PT &b) { return a.x < b.x; } vector<int> find_subset(int l, int u, vector<int> w) { vector <int> ans = {}; for (auto &t : w) c[n] = { t, n }, n++; sort(c, c + n, cmp); ll s = 0; int left = 0, right = 0; for (int i = 0; i < n; i++) { if (s + c[i].x > u) break; s += c[i].x; right = i; } if (right == n - 1 && s < l) return ans; while (right <= n - 1 && s < l) { s -= c[left].x; left++; right++; s += c[right].x; } if (l <= s && s <= u) { for (int i = left; i <= right; i++) ans.push_back(c[i].i); } return ans; }
#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...