- CoVH之柯南购物
- 2009-10-26 21:50:54 @
各位帮忙看下,为什么过不掉?
(我学的我同学的算法)
program p1205(input,output);
var a:array[0..3000] of longint;
g:array[0..3000] of longint;
t:array[0..3000] of longint;
ch,ji,n,i,j,ss:longint;
procedure init;
begin
read(n);
for i:= 1 to n do
read(a[i]);
fillchar(g,sizeof(g),0);
for i:= 1 to n do
inc(g[i]);
for i:= n-1 downto 1 do
for j:= i+1 to n do
if (a[i]>a[j]) and (g[j]>=g[i]) then
g[i]:=g[j]+1;
ji:=1;
for i:= 1 to n do
if ji=0) and (a[j]a[i]) do
begin
if (a[j]>a[i]) and (g[j]=ch+1) then
t[j]:=t[j]+t[i];
dec(j);
end;
end;
ss:= t[0] mod 10000;
write(ji,' ',ss);
writeln;
end;
begin
init;
end.
0 条评论
目前还没有评论...