-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQA.cpp
More file actions
72 lines (63 loc) · 1.26 KB
/
QA.cpp
File metadata and controls
72 lines (63 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef ONPC
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#endif
#include <algorithm>
#include <array>
#include <stack>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
#include <fstream>
using namespace std;
// Debugging macro
#ifdef ONPC
#include "DEBUG.h"
#else
#define debug(...) // No-op for production
#endif
#define int long long
void solve() {
int n, m;
cin >> n >> m;
multiset<int> tickets;
for (int i = 0; i < n; i++) {
int x; cin >> x;
tickets.insert(x);
}
for (int i = 0; i < m; i++) {
int x; cin >> x;
auto it = tickets.upper_bound(x);
if (it == tickets.begin()) {
cout << -1 << '\n';
} else {
--it;
cout << *it << '\n';
tickets.erase(it);
}
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef ONPC
freopen("inputf.txt","r",stdin);
freopen("outputf.txt","w",stdout);
#endif
int t = 1;
//cin >> t;
while(t--) solve();
}