20030103pz @ 2017-07-04 16:52:46
var n,i,max,d,s:longint; a:array[1..10000] of longint;
begin
readln(n);
for i:=1 to n do
read(a[i]);
readln;
i:=1; max:=0;
d:=1; s:=1;
while s<=n do
begin
if a[s]=(a[s+1]-1) then d:=d+1 else d:=1;
if max<d then max:=d;
s:=s+1;
end;
writeln(max);
end.
//这个程序在等差为一时可过,但题目未说,请大神改进。
by 20030103pz @ 2017-07-04 16:54:07
抱歉,程序发错
var a,b:array[0..101,0..101]of longint; m,n,w,p,x,max,i,j,d,c:longint;
procedure find;
begin
for i:=1 to d do
for j:=1 to c do
if a[i,j]=x then exit;
end;
begin
readln(d,c);
for i:=1 to d do
begin
for j:=1 to c do
begin
read(a[i,j]);
b[i,j]:=1;
end;
readln;
end;
x:=1;
for m:=1 to d do
for n:=1 to c do
begin
find;
x:=x+1;
if (a[i,j]<a[i,j+1]) and ((b[i,j]+1)>b[i,j+1]) THEN b[i,j+1]:=b[i,j]+1;
if (a[i,j]<a[i,j-1]) and ((b[i,j]+1)>b[i,j-1]) THEN b[i,j-1]:=b[i,j]+1;
if (a[i,j]<a[i-1,j]) and ((b[i,j]+1)>b[i-1,j]) THEN b[i-1,j]:=b[i,j]+1;
if (a[i,j]<a[i+1,j]) and ((b[i,j]+1)>b[i+1,j]) then b[i+1,j]:=b[i,j]+1;
end;
for i:=1 to d do
for j:=1 to c do
if max<b[i,j] then max:=b[i,j];
writeln(max);
end.