- 导弹拦截
- 2013-09-25 21:18:20 @
program p1303;
uses math;
var
f,a:array[0..25]of longint;
ma,mi,n,i,j:longint;
ss,s:ansistring;
begin
readln(ss); ss:=ss+',';
n:=0;
for i:=1 to length(ss)do
begin
if ss[i]=',' then
begin
inc(n);
val(s,a[n]);
s:='';
end else
s:=s+ss[i];
end;
fillchar(f,sizeof(f),0);
f[1]:=1;
ma:=f[1];
for i:=2 to n do
begin
for j:=1 to i-1 do
if (a[j]>=a[i]) and (f[i]<f[j]) then f[i]:=f[j];
inc(f[i]);
ma:=max(ma,f[i]);
end;
fillchar(f,sizeof(f),0);
f[1]:=1;
mi:=1;
for i:=2 to n do
begin
for j:=1 to i-1 do
if (a[j]<a[i]) and (f[i]<f[j]) then f[i]:=f[j];
inc(f[i]);
mi:=max(mi,f[i]);
end;
writeln(ma,',',mi-1);
end.
1 条评论
-
Towerlight LV 10 @ 2013-09-26 20:24:42
话说大家以后的题解能不能发在题解区里不要往讨论里放……
- 1