#K47402. Maximum Score with No Two Consecutive Moves
Maximum Score with No Two Consecutive Moves
Maximum Score with No Two Consecutive Moves
You are given a sequence of moves represented by n integers. Each integer represents the score earned for that move. However, you are not allowed to take two consecutive moves. Your task is to determine the maximum score you can obtain by selecting moves such that no two selected moves are adjacent in the sequence.
Formally, given an array \(\textbf{moves} = [a_1,a_2,\dots,a_n]\), compute the maximum sum \(S\) such that if you pick \(a_i\) then you cannot pick \(a_{i+1}\). This problem can be solved using dynamic programming.
If the list is empty, the maximum score is 0.
inputFormat
The first line of input contains an integer \(n\), representing the number of moves. The second line contains \(n\) space-separated integers, representing the scores of the moves.
Note: If \(n = 0\), then no moves are provided.
outputFormat
Output a single integer representing the maximum score that can be obtained without taking two consecutive moves.
## sample3
4 5 1
5
</p>