Submission #411322

#TimeUsernameProblemLanguageResultExecution timeMemory
411322hibye1217Detecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms204 KiB
#include "molecules.h" #include <vector> #include <algorithm> #include <iostream> using ll = long long; std::vector<int> find_subset(int l, int u, std::vector<int> w) { sort(w.begin(), w.end()); std::vector<int> ans; int n = w.size(); ll pre = 0, suf = 0; for (int i = 1; i <= n; i++){ pre += w[i-1]; suf += w[n-i]; if (pre > u){ return ans; } if (l <= pre && pre <= u){ for (int j = 0; j < i; j++){ ans.push_back(j); } return ans; } if (l <= suf && suf <= u){ for (int j = n-i; j < n; j++){ ans.push_back(j); } return ans; } if (pre < l && u < suf){ ll sum = pre; for (int j = 0; j+i < n; j++){ if (l <= sum && sum <= u){ for (int k = j; k < j+i; k++){ ans.push_back(k); } return ans; } sum -= w[j]; sum += w[j+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...