diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-07-06 19:08:08 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-07-06 19:08:08 +0200 |
| commit | 96254947699986c59f0dc63d69fd4b76bd3ed43e (patch) | |
| tree | 6c4dca945d7f7427c48be234d827fe4d33be02c5 /02_sorting_and_searching/concert_tickets_1091.cpp | |
| download | cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.tar.gz cses-96254947699986c59f0dc63d69fd4b76bd3ed43e.zip | |
Initial commit
Diffstat (limited to '02_sorting_and_searching/concert_tickets_1091.cpp')
| -rw-r--r-- | 02_sorting_and_searching/concert_tickets_1091.cpp | 25 |
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 | |||
| 6 | int 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 | } | ||
