Problem: Pak Chanek observes that the carriages of a train is always full on morning departure hours and afternoon departure hours. Therefore, the balance between carriages is needed so that it is not too crowded in only a few carriages.
A train contains carriages that are numbered from to from left to right. Carriage initially contains passengers. All carriages are connected by carriage doors, namely for each (), carriage and carriage are connected by a two-way door.
Each passenger can move between carriages, but train regulation regulates that for each , a passenger that starts from carriage cannot go through more than doors.
Define as the most number of passengers in one same carriage after moving. Pak Chanek asks, what is the minimum possible value of ?
Input Format: The first line contains a single integer () — the number of carriages.
The second line contains integers () — the initial number of passengers in each carriage.
The third line contains integers () — the maximum limit of the number of doors for each starting carriage.
Output Format: An integer representing the minimum possible value of .
Note: One strategy that is optimal is as follows:
- people in carriage move to carriage (going through doors).
- people in carriage move to carriage (going through doors).
- people in carriage move to carriage (going through door).
- person in carriage moves to carriage (going through door).
The number of passengers in each carriage becomes .