Submission #108011

#TimeUsernameProblemLanguageResultExecution timeMemory
108011FiloSanzaDetecting Molecules (IOI16_molecules)C++14
100 / 100
66 ms5672 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; const auto NO = vector<int>(0); vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int, int>> v(w.size()); for(int i=0; i<(int)w.size(); i++) v[i] = {w[i], i}; sort(v.begin(), v.end()); long long sum = 0; int lo = 0, hi = 0; while(hi < (int)v.size() && lo <= hi){ if(sum < l) sum += v[hi++].first; if(sum > u) sum -= v[lo++].first; if(sum >= l && sum <= u){ vector<int> sol; for(int i=lo; i<hi; i++) sol.push_back(v[i].second); return sol; } } return NO; }
#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...