Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么WA?就是N^2的DP呀,官方数据都过了……(程序见内)var f,v:longint; b,t:array[1..101,1..101] of longint; procedure init; var i,j:longint; begin readln(f,v); for i:=1 to f do begin for j:=1 to v do read(b[i,j]); readln; end; end; procedure main; var i,j:longint; begin for i:=1 to f+1 do t[i,v+1]:=-maxlongint; for j:=v downto 1 do if t[f,j+1]>b[f,j] then t[f,j]:=t[f,j+1] else t[f,j]:=b[f,j]; for i:=f-1 downto 1 do for j:=v downto 1 do begin t[i,j]:=t[i,j+1]; if t[i+1,j+1]+b[i,j]>t[i,j] then t[i,j]:=t[i+1,j+1]+b[i,j]; end; end; procedure print; begin writeln(t[1,1]); end; begin init; main; print; end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator