Byteocircle
Time limit1sMemory limit128 MB
Find the largest fastest-route travel time between any two cities in a wheel network with a central capital and a rim cycle.
- Level
Hard8 of 10
- Topics
- Shortest path, Graph, Binary search, Sliding window
- Solved
- No attempts yet
Problem
Byteocircle is a country of cities numbered through . Exactly of them lie on a circle, and walking around it you meet cities in that order. Every two neighbouring cities on the circle are joined by a two-way road. The capital, city , sits at the centre of the circle and has a road to every other city.
The travel time along each road is known. The government wants to make travelling between cities easier, so it will pick the two cities that are farthest apart and build an airport in each of them. The distance between two cities is the travel time of the fastest route from one to the other.
Input
The first line contains the number of cities . ()
The second line contains positive integers. The -th of them is the travel time of the road between city and the next city on the circle. The city that follows city is city .
The third line contains positive integers. The -th of them is the travel time of the road between the capital and city .
The travel times of all roads add up to at most .
Output
Print one integer, the travel time between the two farthest cities.
Hint

In the example the two farthest cities are city and city , and the travel time between them is . The airports belong in those two cities.