pascal(25)
发布网友
发布时间:2022-04-24 02:15
我来回答
共1个回答
热心网友
时间:2023-10-21 10:26
program huasheng;
var max,maxi,maxj,i,j,m,n,t:integer;
a:array[1..20,1..20]of integer;
sum:longint;
function next(ni,nj:integer):integer;
var tt,fi,fj:integer;
begin
max:=0;
for fi:=1 to m do
for fj:=1 to n do if a[fi,fj]>max
then begin
max:=a[fi,fj];
maxi:=fi;
maxj:=fj;
end;
next:=abs(maxi-ni)+abs(maxj-nj)+1+maxi;
end;
begin
read(m,n,t);
for i:=1 to m do
for j:=1 to n do read(a[i,j]);
for i:=1 to m do
for j:=1 to n do if a[i,j]>max then
begin
max:=a[i,j];
maxj:=j;
end;
i:=0;j:=maxj;
while next(i,j)<=t do
begin
t:=t-next(i,j)+maxi;
i:=maxi;j:=maxj;
sum:=sum+a[i,j];
a[i,j]:=0;
end;
writeln(sum);
end.
热心网友
时间:2023-10-21 10:26
program huasheng;
var max,maxi,maxj,i,j,m,n,t:integer;
a:array[1..20,1..20]of integer;
sum:longint;
function next(ni,nj:integer):integer;
var tt,fi,fj:integer;
begin
max:=0;
for fi:=1 to m do
for fj:=1 to n do if a[fi,fj]>max
then begin
max:=a[fi,fj];
maxi:=fi;
maxj:=fj;
end;
next:=abs(maxi-ni)+abs(maxj-nj)+1+maxi;
end;
begin
read(m,n,t);
for i:=1 to m do
for j:=1 to n do read(a[i,j]);
for i:=1 to m do
for j:=1 to n do if a[i,j]>max then
begin
max:=a[i,j];
maxj:=j;
end;
i:=0;j:=maxj;
while next(i,j)<=t do
begin
t:=t-next(i,j)+maxi;
i:=maxi;j:=maxj;
sum:=sum+a[i,j];
a[i,j]:=0;
end;
writeln(sum);
end.
热心网友
时间:2023-10-21 10:26
program huasheng;
var max,maxi,maxj,i,j,m,n,t:integer;
a:array[1..20,1..20]of integer;
sum:longint;
function next(ni,nj:integer):integer;
var tt,fi,fj:integer;
begin
max:=0;
for fi:=1 to m do
for fj:=1 to n do if a[fi,fj]>max
then begin
max:=a[fi,fj];
maxi:=fi;
maxj:=fj;
end;
next:=abs(maxi-ni)+abs(maxj-nj)+1+maxi;
end;
begin
read(m,n,t);
for i:=1 to m do
for j:=1 to n do read(a[i,j]);
for i:=1 to m do
for j:=1 to n do if a[i,j]>max then
begin
max:=a[i,j];
maxj:=j;
end;
i:=0;j:=maxj;
while next(i,j)<=t do
begin
t:=t-next(i,j)+maxi;
i:=maxi;j:=maxj;
sum:=sum+a[i,j];
a[i,j]:=0;
end;
writeln(sum);
end.