commit a5490ce98ab84872a4f9c4a6369c7f49353ca068 parent 58a87134b164074107e7a97261810f594e7b289a Author: superpozycja <anna@superpozycja.net> Date: Sun, 27 Oct 2024 14:28:34 +0100 solve concert tickets Diffstat:
A | sorting_and_searching/concert_tickets.cpp | | | 47 | +++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 47 insertions(+), 0 deletions(-)
diff --git a/sorting_and_searching/concert_tickets.cpp b/sorting_and_searching/concert_tickets.cpp @@ -0,0 +1,47 @@ +#include <bits/stdc++.h> + +using namespace std; + +using ui = unsigned int; +using l = long; +using ul = unsigned long; +using ll = long long; +using ull = unsigned long long; + +using vi = vector<int>; +using vui = vector<ui>; +using vl = vector<l>; +using vul = vector<ul>; +using vll = vector<ll>; +using vull = vector<ull>; + +void solve() +{ + int n, m, t; + cin >> n >> m; + multiset<int> h; + for (int i = 0; i < n; i++) { + int tmp; + cin >> tmp; + h.insert(tmp); + } + + for (int i = 0; i < m; i++) { + cin >> t; + auto k = h.upper_bound(t); + if (k == h.begin()) { + cout << "-1\n"; + } else { + cout << *(--k) << "\n"; + h.erase(k); + } + + } +} + +int main() +{ + ios::sync_with_stdio(0); + cin.tie(0); + solve(); +}