pay[i] is what they earn by taking the shift on day i. Working two days in a row is not allowed: every shift has to be followed by at least one day off.
The courier picks which days to work (any number of days, possibly none). Return the largest total they can earn.pay=[5, 1, 1, 5] → 10
The best choice is the first and the last shift: 5 + 5 = 10, and they are not back to back.
pay=[3, 10, 4, 2, 8] → 18
Shifts 1 and 4 (0-based): 10 + 8 = 18. Taking 3 + 4 + 8 = 15 is worse.
pay=[0, 0, 7] → 7
pay ≤ 100pay[i] ≤ 10⁴pay=[5, 1, 1, 5]
10
Run checks the first 3 tests in your browser. Submit checks all 120 tests on the server, hidden ones included.