aboutsummaryrefslogtreecommitdiff
path: root/02_sorting_and_searching/concert_tickets_1091.cpp
diff options
context:
space:
mode:
Diffstat (limited to '02_sorting_and_searching/concert_tickets_1091.cpp')
-rw-r--r--02_sorting_and_searching/concert_tickets_1091.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/02_sorting_and_searching/concert_tickets_1091.cpp b/02_sorting_and_searching/concert_tickets_1091.cpp
new file mode 100644
index 0000000..20333a6
--- /dev/null
+++ b/02_sorting_and_searching/concert_tickets_1091.cpp
@@ -0,0 +1,25 @@
1#include <algorithm>
2#include <iostream>
3#include <set>
4#include <vector>
5
6int main() {
7 size_t n, m;
8 std::cin >> n >> m;
9 std::vector<int> hv(n), t(m);
10 for (size_t i = 0; i < n; i++)
11 std::cin >> hv[i];
12 for (size_t i = 0; i < m; i++)
13 std::cin >> t[i];
14
15 std::multiset<int, std::greater<int>> h(hv.begin(), hv.end());
16
17 for (auto c : t) {
18 if (auto x = h.lower_bound(c); x == h.end()) {
19 std::cout << "-1\n";
20 } else {
21 std::cout << *x << "\n";
22 h.erase(x);
23 }
24 }
25}

Generated with cgit - Back to sebastiano.tronto.net