DWITE Online Computer Programming Contest

Escape and Loot

November 2010
Problem 3

You are being chased! However, you also have a strong attraction towards shiny things and notice, while running, that people carelessly left valuables lying around on the floor. So while trying to escape, you want to pick up the most value possible. You are at the bottom leftmost corner of the field, and you are making your way to the top rightmost corner to escape. The only valid moves are up or to the right, so you are always getting further from the starting point. There is no backtracking.

The input file DATA3.txt will contain 5 cases, each an 8×8 grid, followed by a separating line of dashes. Periods . are empty space, hashes # are walls, and digits are the value of the loot at that location.

The output file OUT3.txt will contain 5 lines, each an integer – the maximum sum value of the loot that can be picked up during the escape in the five test cases.

Sample Input (only 1st shown):
..2.....
..2.....
..2.....
.....9..
...##...
...5#...
........
.3......
--------
Sample Output (only 1st shown):
12