Submission #810306

#TimeUsernameProblemLanguageResultExecution timeMemory
810306petezaDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms304 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(); if(accumulate(w.begin(), w.end(), 0ll) < l) return {}; int cr=0; long long cs = 0; vector<pair<int, int>> vec; for(int i=0;i<n;i++) vec.emplace_back(w[i], i); sort(vec.begin(), vec.end()); deque<int> deq; while(cr < n && cs < l) { cs += vec[cr].first; deq.emplace_back(vec[cr++].second); } if(cs <= u) return vector<int>(deq.begin(), deq.end()); deq.pop_back(); cs -= vec[--cr].first; while(cr < n && cs < l) { cs += vec[cr].first; cs -= w[deq.front()]; deq.emplace_back(vec[cr++].second); } if(cs < l) return {}; return vector<int>(deq.begin(), deq.end()); } /* int main() { vector<int> arr = {6, 8, 8, 7}; auto res = find_subset(15, 17, arr); for(int i=0;i<res.size();i++) cout << res[i] << ' '; }*/
#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...