📄 p1303.pas
字号:
program missile;
const
MAXN=1000;
var
h,d:array[1..MAXN] of integer;
i,j,k,n,best,best2:integer;
c:char;
begin
{readln(n);
for i:=1 to n do
readln(h[i]);}
n:=0;
k:=0;
while not eoln do begin
read(c);
if c=',' then begin
inc(n);
h[n]:=k;
k:=0;
continue;
end;
k:=k*10+ord(c)-ord('0');
end;
inc(n);
h[n]:=k;
fillchar(d,sizeof(d),0);
best:=0;
for i:=1 to n do begin
d[i]:=1;
for j:=1 to i-1 do begin
if (h[j]>=h[i]) and (d[j]+1>d[i]) then begin
d[i]:=d[j]+1;
end;
end;
if d[i]>best then best:=d[i];
end;
best2:=0;
for i:=1 to n do begin
d[i]:=1;
for j:=1 to i-1 do begin
if (h[j]<h[i]) and (d[j]+1>d[i]) then begin
d[i]:=d[j]+1;
end;
end;
if d[i]>best2 then best2:=d[i];
end;
writeln(best,',',best2-1);
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -