Submission #61982

#TimeUsernameProblemLanguageResultExecution timeMemory
61982fallingstarDetecting Molecules (IOI16_molecules)C++14
69 / 100
64 ms4016 KiB
#include "molecules.h" #include <algorithm> using namespace std; vector<int> find_subset(int low, int upp, vector<int> w) { int n = w.size(); vector<int> a(n); for (int i = 0; i < n; ++i) a[i] = i; sort(a.begin(), a.end(), [&](int x, int y) { return w[x] < w[y]; }); int sum = 0; for (int i = 0, j = 0; i < n; ++i) { sum += w[a[i]]; if (sum > upp) sum -= w[a[j++]]; if (j > i) break; if (low <= sum && sum <= upp) return vector<int>(a.begin() + j, a.begin() + i + 1); } 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...