Loading...
Loading...
Loading...
Cash lockers stand in a ring, so the first and the last locker are neighbours. A thief may never open two neighbouring lockers. Print the largest total the thief can take.
Example 1
Input
2 3 2
Output
3
The first and last are neighbours, so take only the 3.
Example 2
Input
1 2 3 1
Output
4
Take 1 and 3 for a total of 4.
Try the problem first. Open one hint at a time.
The first and last lockers cannot both be opened.
Solve the straight row twice: without the first locker, and without the last.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor