Logo
(追記) (追記ここまで)

33725번 - Bitaro the Brave 2 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB55353262.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:

  1. Start with a specific monster $j$ (1ドル ≤ j ≤ N$) and defeat the monsters in order: $j, j + 1, \dots , N$.
  2. If $j ≥ 2,ドル go back and defeat the monsters 1,ドル 2, \dots , j − 1$ in sequence.

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.

제한

  • 2ドル ≤ N ≤ 500,円 000$.
  • 0ドル ≤ A_i ≤ 10^9$ (1ドル ≤ i ≤ N$).
  • 0ドル ≤ B_i ≤ 10^9$ (1ドル ≤ i ≤ N$).
  • Given values are all integers.

서브태스크

번호배점제한
110

$N ≤ 2,円 000,ドル and the minimum initial strength $x$ is 10ドル$ or less.

221

$N ≤ 2,円 000$.

319

The minimum initial strength $x$ is 10ドル$ or less.

422

$B_i = 1$ (1ドル ≤ i ≤ N$).

528

No additional constraints.

예제 입력 1

5
1 3 2 8 6
4 3 1 1 2

예제 출력 1

1
  • Start with an initial strength of 1ドル$.
  • Defeat monsters in the following order:
    1. Defeat monster 1ドル$. Strength increases by 4ドル$ to 5ドル$.
    2. Defeat monster 2ドル$. Strength increases by 3ドル$ to 8ドル$.
    3. Defeat monster 3ドル$. Strength increases by 1ドル$ to 9ドル$.
    4. Defeat monster 4ドル$. Strength increases by 1ドル$ to 10ドル$.
    5. Defeat monster 5ドル$. Strength increases by 2ドル$ to 12ドル$.

This sample input satisfies the constraints of Subtasks 1, 2, 3 and 5.

예제 입력 2

5
1 6 3 3 2
1 2 1 0 1

예제 출력 2

3
  • Start with an initial strength of 3ドル$.
  • Defeat monsters in the following order:
    1. Defeat monster 3ドル$. Strength increases by 1ドル$ to 4ドル$.
    2. Defeat monster 4ドル$. Strength increases by 0ドル$ to 4ドル$.
    3. Defeat monster 5ドル$. Strength increases by 1ドル$ to 5ドル$.
    4. Defeat monster 1ドル$. Strength increases by 1ドル$ to 6ドル$.
    5. Defeat monster 2ドル$. Strength increases by 2ドル$ to 8ドル$.

This sample input satisfies the constraints of Subtasks 1, 2, 3 and 5.

예제 입력 3

10
11 9 8 12 7 7 8 12 9 10
1 1 1 1 1 1 1 1 1 1

예제 출력 3

9

This sample input satisfies the constraints of all the subtasks.

예제 입력 4

7
1125 638 0 37 737 820 1202
23 984 558 350 52 345 580

예제 출력 4

0

This sample input satisfies the constraints of Subtasks 1, 2, 3 and 5.

힌트

출처

Olympiad > Japanese Olympiad in Informatics > JOI 2024/2025 2번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
  • 이 문제의 채점 우선 순위는 2이다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /