multisets can be useful

This commit is contained in:
2024-06-04 01:05:42 +02:00
parent c817cf7f3c
commit 4e39870547
2 changed files with 24 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,23 @@
// Concert Tickets
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n, m; cin >> n >> m;
multiset<ll> price;
for (int i{}; i < n; i++) {ll a; cin >> a; price.insert(a);}
for (int i{}; i < m; i++) {
ll v; cin >> v;
auto it = price.upper_bound(v);
if (it == price.begin()) {
cout << -1 << endl;
} else {
cout << *(--it) << endl;
price.erase(it);
}
}
return 0;
}