maxn=5000;
maxlen=1000;
maxh=20000;
type
hp=record
len:integer;
s:array[1..maxlen] of byte;
end;
var
q,f:array[0..maxn] of longint;
count:array[0..maxn] of hp;
n:integer;
procedure init;
var
i:integer;
begin
readln(n);
for i:=1 to n do
begin
f[i]:=1;
read(q[i]);
end;
end;
function plus(x,y:hp):hp;
var
temp:hp;
i,len:integer;
begin
fillchar(temp,sizeof(temp),0);
if x.len>y.len then len:=x.len else len:=y.len;
for i:=1 to len do
begin
inc(temp.s[i],x.s[i]+y.s[i]);
if temp.s[i]>=10 then
begin
dec(temp.s[i],10);
inc(temp.s[i+1]);
end;
end;
while temp.s[len+1]>0 do inc(len);
temp.len:=len;
exit(temp);
end;
procedure dp;
var
i,j,len:integer;
visit:array[1..maxh] of boolean;
sum:hp;
begin
len:=1;
for i:=2 to n do
for j:=i-1 downto 1 do
begin
if (q[i]<q[j]) and (f[i]<f[j]+1) then f[i]:=f[j]+1;
if f[i]>len then len:=f[i];
end;
for i:=1 to n do
begin
if f[i]=1 then
begin
count[i].len:=1;
count[i].s[1]:=1;
continue;
end;
fillchar(visit,sizeof(visit),0);
for j:=i-1 downto 1 do
begin
if (f[i]=f[j]+1)and not visit[q[j]] and (q[i]<q[j]) then
begin
visit[q[j]]:=true;
count[i]:=plus(count[i],count[j]);
end;
end;
end;
fillchar(visit,sizeof(visit),0);
sum.len:=1;
sum.s[1]:=0;
for i:=n downto 1 do
if (f[i]=len)and not visit[q[i]] then
begin
visit[q[i]]:=true;
sum:=plus(sum,count[i]);
end;
write(len,’ ’);
for i:=sum.len downto 1 do
write(sum.s[i]);
writeln;
end;
begin
init;
dp;
close(input);
close(output);
end.
怎么80分叻?
大牛来看看啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
测评机: Xeost[5]
得分: 80分
提交日期: 2009-5-6 22:33:00
有效耗时: 906毫秒
测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 通过本测试点|有效耗时63ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时63ms
测试结果5: 通过本测试点|有效耗时46ms
测试结果6: 通过本测试点|有效耗时172ms
测试结果7: 通过本测试点|有效耗时171ms
测试结果8: 通过本测试点|有效耗时172ms
测试结果9: 运行错误|普通保护错误
测试结果10: 运行错误|普通保护错误
我无语了。
测评机: Xeost[5]
得分: 80分
提交日期: 2009-5-7 21:32:00
有效耗时: 985毫秒
测试结果1: 通过本测试点|有效耗时172ms
测试结果2: 通过本测试点|有效耗时63ms
测试结果3: 通过本测试点|有效耗时62ms
测试结果4: 通过本测试点|有效耗时63ms
测试结果5: 通过本测试点|有效耗时63ms
测试结果6: 通过本测试点|有效耗时187ms
测试结果7: 通过本测试点|有效耗时188ms
测试结果8: 通过本测试点|有效耗时187ms
测试结果9: 运行错误|普通保护错误
测试结果10: 运行错误|普通保护错误
耗时更多还是80
调试多次才成功
终于AC456了,实际上只要改成30000就行
调试多次才成功
终于AC456了,实际上只要改成30000就行
调试多次才成功
终于AC456了,实际上只要改成30000就行
调试多次才成功