-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1092.cpp
45 lines (43 loc) · 784 Bytes
/
1092.cpp
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
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, m;
bool notable = false;
cin >> n;
vector<int> crain(n);
for (int i = 0; i < n; i++) {
cin >> crain[i];
}
cin >> m;
vector<int> boxz(m);
for (int i = 0; i < m; i++) {
cin >> boxz[i];
}
sort(crain.rbegin(), crain.rend());
sort(boxz.rbegin(), boxz.rend());
int time = 0;
if (crain[0] < boxz[0]) {
cout << -1;
}
else {
while (boxz.size() > 0) {
for (int i = 0; i < n; i++) {
if (boxz.size() > 0) {
for (int j = 0; j < boxz.size(); j++) {
if (crain[i] >= boxz[j]) {
boxz.erase(boxz.begin() + j);
break;
}
}
}
}
time++;
}
cout << time;
}
}