O(nm)先找到最多的一株花生,如果时间够回到起点,就再找到剩下的最多的花生,从一株花生到另一株花生花费的时间是abs(x1-x)+abs(y1-y)+1。var t,m,n,k,s,i,j,x1,y1,x,y,ans:longint; a:array[1..100,1..100] of longint;begin readln(n,m,k); for i:=1 to n do for j:=1 to m do begin read(a[i,j]); if a[i,j]>s then begin s:=a[i,j];x:=i;y:=j;end; end; k:=k-x-2; while k-x+1>=0 do begin a[x,y]:=0;ans:=ans+s; s:=0; for i:=1 to n do for j:=1 to m do if a[i,j]>s then begin s:=a[i,j];x1:=i;y1:=j;end; k:=k-1-abs(x-x1)-abs(y-y1); x:=x1; y:=y1; end; writeln(ans);end.