Submission #1018264

#TimeUsernameProblemLanguageResultExecution timeMemory
1018264eldorbek_008Detecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms436 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans; int n = (int)w.size(); vector<pair<int, int>> a; for (int i = 0; i < n; i++) { a.emplace_back(w[i], i); } sort(a.begin(), a.end()); int i, j; i = j = 0; int sum = 0; bool change = false; while (i < n && j < n) { sum += (change ? 0 : a[j].first); if (sum >= l && sum <= u) { for (int i_ = i; i_ <= j; i_++) { ans.push_back(a[i_].second + 1); } sort(ans.begin(), ans.end()); // cout << sum << '\n'; break; } else if (sum < l) { j += 1; change = false; } else { sum -= a[i].first; i += 1; change = true; } } 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...