Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

You are given an N x M integer grid board, where each cell contains a score. Rows and columns are zero-indexed. A player starts from the top-row cell (0, p) and must reach any cell in the bottom row.

From a cell (i, j), the player may move to any valid destination among:

  • (i + 1, j - 1) diagonally down-left.
  • (i + 1, j) straight down.
  • (i + 1, j + 1) diagonally down-right.
  • (i + 2, j) special straight down jump.

The move (i + 2, j) is a special jump and may be used at most K times. When a special jump is used, the skipped cell (i + 1, j) is not visited and does not contribute to the score.

Test Cases
Input
Output
Expected