Submit | All submissions | Best solutions | Back to list |
EIUPHISTONE2 - Philosopher Stone |
Hogwarts has a chamber with a floor of h × w tiles, each containing philosopher’s stones (1–100). Harry must collect the maximum stones by moving from the first row to the last row, starting at any tile in the first row and moving to a tile directly below or diagonally below (left or right).
Input:
● First line: integer T (number of test cases).
● For each test case:
- Two integers h (1 ≤ h ≤ 100) and w (1 ≤ w ≤ 100).
- h lines, each with w integers representing the stones (0 ≤ m ≤ 100) in each tile.
Output:
For each test case, output the maximum stones Harry can collect.
Example
Input |
Output |
1 6 5 3 1 7 4 2 2 1 3 1 1 1 2 2 1 8 2 2 1 5 3 2 1 4 4 4 5 2 7 5 1 |
32 (Path: 7 → 1 → 8 → 5 → 4 → 7 = 32)
|
Added by: | Ha Minh Ngoc |
Date: | 2025-05-29 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |