cswork / OA打开练习工作台

SalesforceOA #23

Least Hours to Implement Features

估计中等可在线判题

考点(AI 标注)贪心调度前缀和区间

Each feature must be either developed or integrated. There are enough developers, and all development starts at the same time; integration is done one feature at a time by the team lead alone, in parallel with development. Find the shortest time to complete all features.

输入格式

The input gives n, followed by n developmentTime values and n integrationTime values. There are no original numeric bounds; this site adds 1≤n≤200000, and all times are integers in 0..10^9.

输出格式

Output one integer answer.

样例 1

输入:

4
3 4 5 9
3 2 5 5

输出:

5

样例 2

输入:

4
8 10 6 7
1 2 2 1

输出:

6

样例 3

输入:

2
0 5
9 0

输出:

0

样例说明

The outputs of the three public examples are, in order: 5; 6; 0. They have been checked by independent enumeration or direct simulation.