logo AlgoBeat OnlineJudge
登录 注册

#217796. [JAG 2026 Summer Camp #2] Vibe Coding

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

题目描述

Shobon has decided to use a generative AI to help develop a software project. The project consists of tasks. Each task () has a predetermined implementation workload and complexity .

Shobon can proceed with these tasks in any order. However, he cannot work on more than one task at the same time.

Each task () can be completed in one of the following two ways:

  • Implement the task manually. Shobon writes the code himself, which takes units of time.
  • Use the generative AI. To make the AI generate correct code, Shobon explains the current task and all previously completed tasks to the AI. Let be the sum of the complexities of all previously completed tasks. Preparing this explanation takes units of time. The AI then finishes the implementation instantly, so no additional implementation time is required. Thus, completing this task by using the AI takes a total of units of time.

Regardless of which method is used, once task is completed, its complexity is included in future values of when using the generative AI.

Find the minimum total time required to complete all tasks.

输入格式

The input consists of three lines in the following format.

N
A_1 A_2 ... A_N
B_1 B_2 ... B_N

In the first line, the number of tasks, , is given (). The second line contains integers, , each between and , inclusive, representing the implementation workloads of the tasks. The third line contains integers, , each between and , inclusive, representing the complexities of the tasks.

输出格式

Output in a line the minimum total time required to complete all tasks.

样例

样例输入 1

3
10 6 10
5 2 4

样例输出 1

18

样例输入 2

1
4
10

样例输出 2

4

样例输入 3

5
100 100 100 100 100
5 1 4 2 3

样例输出 3

35

样例输入 4

12
18 7 25 12 30 5 16 22 9 28 14 20
6 11 2 8 1 13 5 3 10 4 9 7

样例输出 4

118

数据范围与提示

For Sample Input 1, consider using the generative AI for tasks and in this order, and then implementing task manually.

  • When task is started, no task has been completed yet. This task takes units of time.
  • When task is started, task has been completed. This task takes units of time.
  • Finally, implementing task manually takes units of time.

Thus, all tasks can be completed in units of time, which is the minimum possible.