Switch
InterviewTime limit1sMemory limit1024 MB
Choose windows of three consecutive seconds, none overlapping, to double their points, and find the maximum total score.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Array
- Solved
- No attempts yet
Problem
At second , the game gives points. The game lasts seconds. To earn extra points, you can press a switch at second . Pressing it doubles the points earned at seconds , , and . After you press the switch at second , you can press it again starting from second .
Find the maximum total score you can earn by pressing the switch appropriately while the game runs.
Input
The first line contains the number of scoring seconds .
The second line contains the integers for each second , separated by spaces.
Output
Print the maximum total score you can earn.