n cells in a row, numbered 0 to n - 1, and each cell has a score that starts at zero. A robot stands to the left of the row, just before cell 0 (think of it as position -1).
The robot makes at most moves moves. Each move takes it one cell left or right, and the cell i it lands on adds gains[i] to its score. After the first move the robot must stay inside the row.
Return the largest possible value of the smallest score among all cells.gains=[3, 5], moves=3 → 5
Moves: into cell 0 (scores [3, 0]), to cell 1 ([3, 5]), back to 0 ([6, 5]). The minimum is 5.
gains=[4, 1, 2], moves=2 → 0
Two moves are not enough to reach cell 2, so its score stays 0.
gains=[2, 3, 1], moves=7 → 2
len(gains) ≤ 5 · 10⁴gains[i] ≤ 10⁶moves ≤ 10⁹gains=[3, 5], moves=3
5
Run checks the first 3 tests in your browser. Submit checks all 97 tests on the server, hidden ones included.