logo AlgoBeat OnlineJudge
登录 注册

#212133. [NOISG 2025 Prelim] Train Or Bus

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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

To travel between cities and , you have two transportation options:

  • Take a train, which takes units of time.
  • Take a bus, which takes units of time.

Determine the minimum total time required to travel from city to city .

输入格式

Your program must read from standard input.

The first line of input contains one integer .

The following lines of input each contain one integer. The -th of these lines contains .

The following lines of input each contain one integer. The -th of these lines contains .

输出格式

Your program must print to standard output.

Output a single integer, the shortest time taken to travel from city to city .

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

样例

样例输入 1

3
7
7
5
9
8
1

样例输出 1

15

数据范围与提示

Subtasks

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

  • for all
  • for all

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

Subtask Marks Additional Constraints
Sample test cases
No additional constraints

Sample Test Case 1 Explanation

You start at city . You then:

  • Take the train from city to city ( units of time taken).
  • Take the train from city to city ( units of time taken).
  • Take the bus from city to city ( unit of time taken).

The total time taken is .