- 导弹拦截
- 2013-03-16 14:55:20 @
var
a,f1,f2:array[0..30]of integer;
i,j,n,t,max1,max2,code:integer;
s:string;
begin
readln(s); n:=0;
while pos(',',s)>0 do
begin
t:=pos(',',s);
inc(n);
val(copy(s,1,t-1),a[n],code);
delete(s,1,t);
end;
inc(n);
val(s,a[n],code);
max1:=0; max2:=0;
for i:=1 to n do
begin
f1[i]:=1; f2[i]:=1;
for j:=1 to i-1 do
begin
if (a[i]<=a[j])and(f1[j]+1>f1[i]) then f1[i]:=f1[j]+1;
if (a[i]>a[j])and(f2[j]+1>f2[j]) then f2[i]:=f2[j]+1;
end;
if f1[i]>max1 then max1:=f1[i];
if f2[i]>max2 then max2:=f2[i];
end;
writeln(max1,',',max2-1);
end.
1 条评论
-
mrw LV 10 MOD @ 2013-03-16 16:14:30
贴代码前请查看编辑栏的markdown详细帮助,让代码正确显示并提高其可读性
- 1