Company: Amazon HackOn
Difficulty: easy
Eldoria Maze Energy Check In the land of Eldoria there is a mystical maze laid out as a grid with M rows and N columns. Each cell carries an energy cost , and entering that cell consumes exactly that much energy. You are an adventurer. You start on the top-left cell (1, 1) and you want to end on the bottom-right cell (M, N) . From any cell you may step only down or only right , and you may never step outside the grid. Entering a cell always costs its energy — including the starting cell and the destination cell , so a route's total cost is the sum of every cell it stands on, counting (1, 1) and (M, N) . You begin with an energy supply of E . Decide whether some legal route from (1, 1) to (M, N) has a total cost of at most E . Input Format The first line contains an integer M — the number of rows. The second line contains an integer N — the number of columns. The third line contains an integer E — the energy available. The next M lines each contain N space-separated integers — the energ