#P12192. Minimum Travel Time
Minimum Travel Time
Minimum Travel Time
You are a tourist who wishes to explore a sequence of cities. There are \(n+1\) cities, numbered from 1 to \(n+1\) in order. To travel between city \(i\) and city \(i+1\), you have two transportation options:
- Take a train: it takes \(a[i]\) units of time.
- Take a bus: it takes \(b[i]\) units of time.
Your task is to determine the minimum total time required to travel from city 1 to city \(n+1\) by choosing the faster transportation option for each segment.
Note: For each segment \(i\) (where \(1 \leq i \leq n\)), the optimal time is \(\min(a[i], b[i])\). The answer is the sum of these minimal times.
inputFormat
The first line contains an integer \(n\) denoting the number of segments between the \(n+1\) cities.
The second line contains \(n\) space-separated integers \(a[1], a[2], \ldots, a[n]\) representing the time taken by the train for each segment.
The third line contains \(n\) space-separated integers \(b[1], b[2], \ldots, b[n]\) representing the time taken by the bus for each segment.
outputFormat
Output a single integer, the minimum total travel time from city 1 to city \(n+1\).
sample
3
3 6 1
4 2 3
6