Bitaro the Brave 2
시간 제한: 1000ms메모리 제한: 2048MB출처: JOI 2024-2025 본선BOJ 33725
문제
Bitaro, the brave hero, has set out on an adventure to defeat monsters.
Bitaro has a strength value, denoted as , which starts at an initial value. There are monsters, each labeled with a number from to . To defeat the -th monster (1 ≤ i ≤ N), Bitaro must have a strength of at least . Defeating the -th monster increases Bitaro’s strength by .
Bitaro wants to defeat all the monsters using the following strategy:
- Start with a specific monster (1 ≤ j ≤ N) and defeat the monsters in order: .
- 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 required for Bitaro to defeat all the monsters.
입력
Read the following data from the standard input.
출력
Output a single integer, the minimum initial strength required for Bitaro to defeat all the monsters.
예제
예제 1
입력
5 1 3 2 8 6 4 3 1 1 2
출력
1
예제 2
입력
5 1 6 3 3 2 1 2 1 0 1
출력
3
예제 3
입력
10 11 9 8 12 7 7 8 12 9 10 1 1 1 1 1 1 1 1 1 1
출력
9
예제 4
입력
7 1125 638 0 37 737 820 1202 23 984 558 350 52 345 580
출력
0
코드를 제출하려면 로그인하세요.