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 |
Re:鄙视暴力!!其实我也16MS~~DP代码 不准抄袭,In Reply To:这道题的数据很弱嘛,暴力都能过。O(n^4)的算法、、、、、、 Posted by:070220219 at 2009-11-08 14:26:42 var i,j,k,x,y,z,n,s,max,x1,y1,x2,y2:longint; a,b:array[0..1000,0..1000]of longint; begin readln(n); for i:=1 to n do for j:=1 to n do begin read(a[i,j]); b[i,j]:=b[i,j-1]+a[i,j]; end; max:=0; for i:=1 to n do for j:=i to n do begin s:=0;x:=0; for k:=1 to n do begin s:=s+b[k,j]-b[k,i-1]; if s>max then begin max:=s; x1:=x;x2:=k; y1:=i;y2:=j; end; if s<0 then begin s:=0;x:=k+1;end; end; end; writeln(max); end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator