Loot on a Ring Road
The same no-two-adjacent looting, but the houses form a circle — the first and last house are adjacent too.
Input: the first line has N; the second line has the N loot values.
Output: the maximum loot on the circular street.
Constraints:
- 1 ≤ N ≤ 105
- 0 ≤ ai ≤ 104
Sample Tests
Input 1
4 2 3 2 3
Output 1
6
Input 2
1 5
Output 2
5
Discussion (opens after you solve — no spoilers before)
No comments yet.