Elfnt just walked into an all-you-can-eat vegan buffet, represented by an grid. Each cell holds a food tray with a certain amount of fresh salad leaves. Initially, Elfnt starts at position (0-indexed) and is eager to eat as much as possible!
Elfnt can smell trays within a Manhattan distance of at most from his current position. He greedily eats according to the following rules:
0 (indicating an empty plate).0 leaves, Elfnt stops moving and eating immediately.Note:
The first line contains three integers , , and — the number of rows, the number of columns, and the maximum Manhattan distance Elfnt can smell.
The next lines each contain integers, representing the initial amount of leaves on each tray.
The last line contains two integers and , representing Elfnt's starting row and column coordinates.
0 leaves, all leaf values across the buffet are unique).Output a single integer representing the total amount of salad leaves Elfnt consumes before he stops, followed by a new line.