Submission #1018278

#TimeUsernameProblemLanguageResultExecution timeMemory
1018278eldorbek_008Detecting Molecules (IOI16_molecules)C++17
100 / 100
39 ms4412 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; long long 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); } 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...