| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 55 | 35 | 32 | 62.745% |
Bitaro, the brave hero, has set out on an adventure to defeat monsters.
Bitaro has a strength value, denoted as $x,ドル which starts at an initial value. There are $N$ monsters, each labeled with a number from 1ドル$ to $N$. To defeat the $i$-th monster (1ドル ≤ i ≤ N$), Bitaro must have a strength of at least $A_i$. Defeating the $i$-th monster increases Bitaro’s strength by $B_i$.
Bitaro wants to defeat all the monsters using the following strategy:
Given the information about the monsters, write a program to determine the minimum initial strength $x$ required for Bitaro to defeat all the monsters.
Read the following data from the standard input.
$N$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_N$
Output a single integer, the minimum initial strength $x$ required for Bitaro to defeat all the monsters.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | $N ≤ 2,円 000,ドル and the minimum initial strength $x$ is 10ドル$ or less. |
| 2 | 21 | $N ≤ 2,円 000$. |
| 3 | 19 | The minimum initial strength $x$ is 10ドル$ or less. |
| 4 | 22 | $B_i = 1$ (1ドル ≤ i ≤ N$). |
| 5 | 28 | No additional constraints. |
5 1 3 2 8 6 4 3 1 1 2
1
This sample input satisfies the constraints of Subtasks 1, 2, 3 and 5.
5 1 6 3 3 2 1 2 1 0 1
3
This sample input satisfies the constraints of Subtasks 1, 2, 3 and 5.
10 11 9 8 12 7 7 8 12 9 10 1 1 1 1 1 1 1 1 1 1
9
This sample input satisfies the constraints of all the subtasks.
7 1125 638 0 37 737 820 1202 23 984 558 350 52 345 580
0
This sample input satisfies the constraints of Subtasks 1, 2, 3 and 5.