#C. CS240 Project Problem 2

    传统题 1000ms 256MiB

CS240 Project Problem 2

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

A fastidious farmer wants to pick apples from the apple trees in his orchard. His trees are arranged in a circle, so that the first tree is a neighbor of the last one. To keep his orchard beautiful, he cannot pick apples from neighboring trees. You are given the number of apples on each tree. Design an algorithm for the farmer to pick the maximum number of apples, and output this quantity.

Format

Input

An array AA of NN numbers, where NN is the number of apple trees, and AA indicates the number of apples on each tree.

Output

The maximum number of apples the farmer can pick which satisfies the above condition.

Constraints

1N1001\leq N\leq 100 0Ai10000\leq A_{i}\leq 1000 for AiAA_{i}\in A

Samples

[1, 2, 3]
3
[1, 2, 3, 1]
4

CS240 project Problem

未参加
状态
已结束
规则
IOI
题目
5
开始于
2023-5-16 10:00
结束于
2023-6-6 23:59
持续时间
518 小时
主持人
参赛人数
92