// Take the peanuts according to the map. The maximum number of peanuts is obtained each time. Within the limited number of steps, the maximum number of peanuts can be obtained! You can use greed! # Include "cstdio" # include "iostream" # include "math. H "using namespace STD; int map [60] [60]; int main () {int TC, m, n, k, I, j, totaltime, Curi, curj, x, Y, Max, sum; scanf ("% d", & TC); While (TC --) {scanf ("% d", & M, & N, & K); totaltime = 0; for (I = 1; I <= m; I ++) for (j = 1; j <= N; j ++) scanf ("% d", & map [I] [J]); totaltime = 0, Curi = 0, curj = 0, sum = 0; while (1) {max = 0; X = Curi; y = curj; for (I = 1; I <= m; I ++) for (j = 1; j <= N; j ++) {If (max <map [I] [J]) {max = map [I] [J]; Curi = I; curj = J ;}} if (x = 0) y = curj; If (totaltime + ABS (INT) (Curi-x) + ABS (INT) (curj-y) + 1 + Curi <= k) {sum + = max; totaltime + = ABS (INT (Curi-x )) + ABS (INT (curj-y) + 1; Map [Curi] [curj] =-1; X = Curi; y = curj ;} else {cout <sum <Endl; break ;}} system ("pause ");}