-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1092.cpp
More file actions
46 lines (40 loc) · 951 Bytes
/
1092.cpp
File metadata and controls
46 lines (40 loc) · 951 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int n, m;
int c[51];
int box[10001];
bool check[10001];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int answer = 0;
cin >> n;
for (int i = 0; i < n; i++) cin >> c[i];
cin >> m;
for (int i = 0; i < m; i++) cin >> box[i];
sort(c, c + n, greater<int>());
sort(box, box + m, greater<int>());
if (c[0] < box[0]) {
cout << "-1\n";
return 0;
}
int cnt = m;
int idx = 0;
while (1) {
for (int i = 0; i < n; i++) {
for (int j = idx; j < m; j++) {
if (c[i] >= box[j] && !check[j]) {
check[j] = true;
if (i == 0) {
idx = j + 1;
}
cnt--;
break;
}
}
}
answer++;
if (cnt == 0) break;
}
cout << answer << "\n";
}