Loading...
Loading...
Loading...
A row of lockers holds cash amounts. A thief may open any locker, but never two lockers that are next to each other. Print the largest total the thief can take.
Example 1
Input
2 7 9 3 1
Output
12
Take 2, 9 and 1.
Example 2
Input
5
Output
5
Try the problem first. Open one hint at a time.
For each locker choose between skipping it and taking it.
Taking it adds its amount to the best total two lockers back.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor