Author: | И. Блинов | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 512 Mb | |
Output file: | Standard output |
At the moment, there are n people waiting in line for a bus. The inspector is in position k in the queue and must leave immediately!
Fortunately, there are b buses available, where the i-th bus can hold ci passengers excluding the driver. All people in the line have a driver’s license, meaning any of them can be hired to fill a driver's seat. The skill level of the j-th person is pj, indicating that they can drive a bus with a capacity of at most pj. All hired drivers leave the line and take the driver's seat in the buses. Hiring the inspector is not allowed, as it would look suspicious.
What is the minimum number of drivers from the line that must be hired to ensure the inspector departs immediately?
The first line contains two integers, n and k.
The second line contains n integers, pj.
The third line contains a single integer, b.
The fourth line contains b integers, ci.
Output a single integer: the minimum number of drivers that must be hired so the inspector can leave immediately. If this is impossible, output "-1".
1 ≤ n, b ≤ 100000 1 ≤ pi, ci ≤ 100000
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|