← 返回 cisco 的题目列表Maximum Chocolates from Jars
类型:online_judge
There is a set of N jars containing chocolates. Some of them may be empty. Determine the maximum number of chocolates Andrew can pick from the jars given that he cannot pick from jars next to each other.
Problem - Solving Restrictions: 1 < N <= 1000
Input Description: The first line of input consists of an integer - numJars, representing the number of jars (N). The next line consists of N space-separated integers representing the number of chocolates in each jar.
Output Description: Print the maximum number of chocolates that can be picked from the jars in such a way that the chocolates are not picked from jars next to each other.
Example: Input: 6 5 30 99 60 5 10 Output: 114
Example
Input
6
5 30 99 60 5 10