Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Tìm Tổng MAX
SUBMITTED BY:
Guest
DATE:
Nov. 21, 2014, 10:11 a.m.
FORMAT:
Text only
SIZE:
858 Bytes
Raw
Download
Tweet
HITS:
1219
Go to comments
Report
PROGRAM Tongmax;
USES crt;
VAR a:ARRAY[1..10000] OF LONGINT;
f1,f2:TEXT;
S,k,l,n,i,smax,kmax,lmax: LONGINT;
PROCEDURE Ganvadoc;
VAR i:LONGINT;
BEGIN
Assign(f1,'Tongmax.INP');
Assign(f2,'Tongmax.OUT');
Reset(f1);
Rewrite(f2);
Readln(f1,N);
FOR i:= 1 TO N DO
Readln(f1,a[i]);
Close(f1);
END;
PROCEDURE Timtongmax;
BEGIN
k:=N;
smax:= -10000000 ;
FOR l:=1 TO N DO
BEGIN
REPEAT
BEGIN
FOR i:=l TO k DO
S:= a[i] + S;
IF S> Smax THEN
BEGIN
Smax:=S;
lmax:=l;
kmax:=k;
END;
END;
dec(k);
S:=0;
UNTIL l>k;
k:=N;
END;
END;
PROCEDURE Vietra;
BEGIN
Writeln(f2,lmax);
Writeln(f2,kmax);
Write(f2,Smax);
Close(f2);
END;
BEGIN
Ganvadoc;
Timtongmax;
Vietra;
END.
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus