Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- int main() {
- int n, m;
- cin >> n >> m;
- multiset<int> prices;
- for (int i = 0; i < n; i++) {
- int price;
- cin >> price;
- prices.insert(price);
- }
- for (int i = 0; i < m; ++i) {
- int castomer;
- cin >> castomer;
- auto p = prices.upper_bound(castomer);
- if (p == prices.begin()) {
- cout << -1 << endl;
- continue;
- }
- p--;
- cout << *p << endl;
- prices.erase(p);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment