A flight company has to schedule a journey of \(N\) groups of people from the same source to the same destination. Here, \(A_1,\ A_2,\ ...,\ A_N\) represents the number of people in each group. All groups are present at the source. The flight company has \(M\) planes where \(B_1,\ B_2,\ ...,\ B_m\) represents the capacity of each plane.
You are required to send all groups to destination with the following conditions:
- Each plane can travel from the Source to Destination with only one group at a time such that capacity of a plane is enough to accommodate all people in that group.
- All people belonging to the same group travel together.
- Every plane can make multiple journeys between source and destination.
- It costs 1 unit of time to travel between source to destination and vice versa.
Note: Multiple planes can fly together and also it is not necessary for planes to end their journey at the source.
Determine the minimum time required to send all groups from the source to the destination.
Input format
- The first line contains two integers \(N\) and \(M\).
- The next line contains \(N\) space-separated integers \(A_1,\ A_2,\ ...,\ A_N\).
- The next line contains \(M\) space-separated integers \(B_1,\ B_2,\ ...,\ B_m\).
Output format
Print a single integer denoting minimum time required to send all groups to the destination. If it is not possible to perform this operation, then print -1.
Constraints
\(1 \le N,\ M \le 1e5\\ 1 \le A_i,\ B_i \le 1e9\)