NOI Contest Archive

Archive / 2021 / Selection Test

Maximum Power Battery Array

Medium · National Olympiad in Informatics Sri Lanka - Screening Test 2021

The asymmetric battery array is a line of batteries placed sequentially. Each battery has a different amount of power.

If Tony chooses to activate the battery n, he can’t draw power from surrounding batteries.

Your task is to help Tony calculate the maximum power he can get out of this asymmetric battery array.

Input Format

Output Format

A single integer P, indicating the maximum power that can be generated.

Constraints

Sample Input 0

4
1
2
3
1

Sample Output 0

4

Sample Input 1

5
2
7
9
3
1

Sample Output 1

12