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 |
帮我看看,我想死了(pascal)var n,i,j,jl1,jl2:integer; a:array[0..100000]of longint; s:array[0..100000]of longint; max1,max2:longint; function pd(n,m:integer):boolean; var j:integer; begin pd:=true; for j:=n to m do if a[j]<0 then pd:=false; end; procedure main; begin for i:=1 to n do for j:=1 to i do s[i]:=a[j]+s[i]; max1:=a[1]; for i:=1 to n do for j:=1 to i do if max1<s[i]-s[j-1] then begin max1:=s[i]-s[j-1]; jl1:=i; jl2:=j; end; max2:=a[1]; for i:=0 to n-2 do for j:=1 to i do if (max2<s[i]-s[j-1])and(i<>jl1)and(j<>jl2) then max2:=s[i]-s[j-1]; end; begin readln(n); while n<>0 do begin max1:=0;max2:=0; fillchar(a,sizeof(a),0); fillchar(s,sizeof(s),0); for i:=1 to n do read(a[i]);readln; main; writeln(max1+max2); readln(n); end; end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator