subject
Engineering, 04.05.2020 22:36 Vauzh

Grid Gobble is a game played on a rectangular grid with r rows and cc columns, where each cell in the grid contains a positive integer. A game consists of r moves.
For your first move, you pick a number n from the bottom row. Your score for that move is n.
For each subsequent move, you pick from the next row up. You can pick the number directly above your previous pick, in which case your score increases by that number. Alternatively, you can pick the number diagonally above to either the left or the right, in which case your score decreases by that number. (If your previous move was in the first column, "diagonally above to the left" wraps around to the last column; if your previous move was in the last column, "diagonally above to the right" wraps around to the first column.) When you eventually pick a number from the top row the game is over.
For example, consider this grid
4 9 4
3 1 2
3 5 8
The best sequence of moves is to choose 8 from the bottom row for +8+8, 1 from the middle row for −1−1, and 9 from the top row for +9+9, as illustrated with the boldface numerals. These moves yield a score of 16.
Input
The first line contains the number of rows r and columns cc, where 2≤≤10002≤r≤1000 and 3≤c≤10003≤c≤1000.
The remaining r lines of the input each contain cc integers that lie between 1 and 1000000, inclusive. The first line corresponds to the topmost row of the board and so on down to the last line, which corresponds to the bottommost row of the board.
Output
Print the maximum score possible from the board.
Sample Input 1 Sample Output 1
3 3
4 9 4
3 1 2
3 5 8
16

Sample Input 2 Sample Output 2
3 4
9 2 1 3
3 7 6 1
1 2 3 9
15

Sample Input 3 Sample Output 3
5 4
1 1 1 10000
1 1 1 1
10000 1 1 1
1 1 1 1
1 1 1 10000
29998
Detailed Pseudocode of this is the help that i need.

ansver
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 03:10, lauriepdx17
What precautions should you take to prevent injuries when dealing with heavy loads?
Answers: 1
image
Engineering, 04.07.2019 18:10, keigleyhannah30
Aplate clutch has a single pair of mating friction surfaces 250-mm od by 175-mm id. the mean value of the coefficient of friction is 0.30, and the actuating force is 4 kn. a) find the maximum pressure and the torque capacity using the uniform-wear model. b) find the maximum pressure and the torque capacity using the uniform-pressure model.
Answers: 3
image
Engineering, 04.07.2019 18:20, DroctorWellsfan
Inspection for bearing condition will include: (clo4) a)-color b)-smell c)-size d)-none of the above
Answers: 1
image
Engineering, 04.07.2019 19:10, jimena15
10 kg of co2 is initially contained at 400 kpa and 300 k. the gas constant for carbon dioxide is 189 j/lkg k) and has a specific heat ratio, k, of 1.289. isentropic expansion then occurs until the pressure is 200 kpa. a) determine the initial volume of co2 in m. b) determine the final temperature in k. c) determine the work done by the system during the expansion kl.
Answers: 2
You know the right answer?
Grid Gobble is a game played on a rectangular grid with r rows and cc columns, where each cell in th...

Questions in other subjects:

Konu
Mathematics, 18.10.2020 23:01
Konu
Biology, 18.10.2020 23:01
Konu
Mathematics, 18.10.2020 23:01