Submission #491979

#TimeUsernameProblemLanguageResultExecution timeMemory
491979collodelDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms256 KiB
#include "molecules.h" #include <deque> #include <algorithm> #include <numeric> using namespace std; using ll = long long; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int i = 0; int N = w.size(); ll sum = 0; vector<int> ord(N); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](int a, int b){return w[a] < w[b];}); deque<ll> ans; for(int j = 0; j < N; ++j) { sum += w[ord[j]]; // prendi l'elemento ans.push_back(j); // togli gli elementi sbagliati while(sum > u) { sum -= w[ord[i]]; ans.pop_front(); i++; } if(sum >= l) { vector<int> ret; for(auto &x : ans) ret.push_back(x); return ret; } } // nessuna risposta 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...