-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1092.cpp
More file actions
39 lines (34 loc) · 857 Bytes
/
1092.cpp
File metadata and controls
39 lines (34 loc) · 857 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
#include <bits/stdc++.h>
using namespace std;
int N, M;
int ans;
int main(void) {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> N;
vector<int> crane(N);
for(int i = 0; i < N; i++)
cin >> crane[i];
sort(crane.begin(), crane.end(), greater<int>());
cin >> M;
vector<int> box(M);
for(int i = 0; i < M; i++)
cin >> box[i];
sort(box.begin(), box.end(), greater<int>());
if(box[0] > crane[0]){
cout << -1 << '\n';
return 0;
}
while(!box.empty()){
ans++;
for(int i = 0; i < crane.size(); i++){
for(int j = 0; j < box.size(); j++){
if(crane[i] >= box[j]){
box.erase(box.begin()+j);
break;
}
}
}
}
cout << ans << '\n';
return 0;
}