Return Pickup
Time limit1sMemory limit1024 MB
Find the minimum time for a truck starting at position 0 to collect every house's item after its release time and return to 0.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Intervals
- Solved
- No attempts yet
문제
As shown in the figure below, houses are on a straight road, numbered to from left to right. The position of house () is ().

A delivery company uses one truck to visit all houses and collect returned items. The truck leaves the company at position at time . House puts out its returned item at time . The truck moves at speed , so moving a distance takes time. If needed, the truck can stop and wait in place.
When the truck passes the position of a house with a returned item, it collects the item instantly. Collecting an item takes time. So the truck can collect the item from house if it passes position at time or later.
Given the house positions and the times when each item is put out, write a program that finds the minimum time for the truck to collect all items and return to the company.
입력
The first line contains , the number of houses with returned items.
The second line contains the positions , separated by spaces.
The third line contains the times at which each house puts out its item, separated by spaces.
출력
Print the minimum time for the truck to collect all items and return to the company.
제한
- All given numbers are integers.
- ()