View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

You are given cookies that are lined up in a row. Each cookie has a tastiness value, . You want to maximize the sum of the tastiness values of the cookies that you eat. However, you can only eat cookies that are not adjacent to each other.

#### Input Specification

The first line will contain the integer .

The second line will contain integers, .

#### Output Specification

The maximum sum of the tastiness values of the cookies you eat, satisfying the constraint that you may not eat cookies that are adjacent to one other.

No further constraints.

#### Sample Input 1

3
1 7 5

#### Sample Output 1

7

#### Explanation for Sample 1

The maximum tastiness sum would be to only take the cookie with a tastiness value of for a total sum of .

#### Sample Input 2

5
1 10 4 7 8

#### Sample Output 2

18