luogu#P12192. [NOISG 2025 Prelim] Train Or Bus

[NOISG 2025 Prelim] Train Or Bus

题目描述

You are a tourist who wishes to explore some cities. There are n+1n + 1 cities, numbered from 11 to n+1n + 1 in sequence. There are some buses and trains running between these cities.

To travel between cities ii and i+1i + 1, you have two transportation options:

  • Take a train, which takes a[i]a[i] units of time.
  • Take a bus, which takes b[i]b[i] units of time.

Determine the minimum total time required to travel from city 11 to city n+1n + 1.

输入格式

Your program must read from standard input.

The first line of input contains one integer nn.

The following nn lines of input each contain one integer. The ii-th of these lines contains a[i]a[i].

The following nn lines of input each contain one integer. The ii-th of these lines contains b[i]b[i].

输出格式

Your program must print to standard output.

Output a single integer, the shortest time taken to travel from city 11 to city n+1n + 1.

The output should contain only a single integer. Do not print any additional text such as Enter a number or The answer is.

3
7
7
5
9
8
1
15

提示

Subtasks

For all testcases, the input will satisfy the following bounds:

  • 1n101 \leq n \leq 10
  • 1a[i]101 \leq a[i] \leq 10 for all 1in1 \leq i \leq n
  • 1b[i]101 \leq b[i] \leq 10 for all 1in1 \leq i \leq n

Your program will be tested on input instances that satisfy the following restrictions:

Subtask Marks Additional Constraints
00 Sample test cases
11 100100 No additional constraints

Sample Test Case 1 Explanation

You start at city 11. You then:

  • Take the train from city 11 to city 22 (77 units of time taken).
  • Take the train from city 22 to city 33 (77 units of time taken).
  • Take the bus from city 33 to city 44 (11 unit of time taken).

The total time taken is 1515.