Submission #867280

#TimeUsernameProblemLanguageResultExecution timeMemory
867280AtabayRajabliDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms500 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int L, int U, std::vector<int> w) { int n = w.size(); std::vector<pair<int, int>> v(n); for(int i = 0; i<n; i++) { v[i] = make_pair(w[i], i); } sort(v.begin(), v.end()); set<int> s; int l = 0, r = 0, sum = 0; while(r < n) { sum += v[r].first; s.insert(v[r].second); while(sum > U) { sum -= v[l].first; s.erase(l); l++; } if(L <= sum && sum <= U) { vector<int> ans; for(int i : s)ans.push_back(i); return ans; } r++; } return std::vector<int>(0); }
#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...