Submission #636121

#TimeUsernameProblemLanguageResultExecution timeMemory
636121nehasaneDetecting Molecules (IOI16_molecules)C++14
100 / 100
46 ms4104 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector <int> ans; vector <pair <int, int>> wt(n); for (int i = 0; i < n; i++) wt[i] = {w[i], i}; sort(wt.begin(), wt.end()); int lo = 0, hi = 0; long long sum = 0; while (sum < l || sum > u) { if (sum < l) { if (hi == n) break; sum += wt[hi].first; hi++; } else { if (lo > hi) break; sum -= wt[lo].first; lo++; } } if (sum < l || sum > u) return ans; for (int i = lo; i < hi; i++) ans.push_back(wt[i].second); 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...