From 1a8e1e68759611a66ae116771da5f376c95a3b9f Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Sun, 12 Feb 2017 16:18:20 +0700 Subject: Update others/volume1 --- others/volume1/020.pas | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'others/volume1/020.pas') diff --git a/others/volume1/020.pas b/others/volume1/020.pas index 4d11bd2..f37db27 100644 --- a/others/volume1/020.pas +++ b/others/volume1/020.pas @@ -9,24 +9,22 @@ begin read(a[l]); a[n] := 0; max := 0; - l := 0; - h := 0; - l0 := 0; - while l0 < n do - for h0 := l0 to n - 1 do - if a[h0] * a[h0 + 1] >= 0 then + h0 := 0; + l := 0; + while l < n do + for h := l to n - 1 do + if a[h] * a[h + 1] >= 0 then begin - if max < h0 - l0 then + if max < h - l then begin - max := h0 - l0; - l := l0; - h := h0 + max := h - l; + l0 := l; + h0 := h end; - l0 := h0 + 1; + l := h + 1; break end; - writeln(l + 1, ' ', h + 1) -end. + writeln(l0 + 1, ' ', h0 + 1) end. -- cgit 1.4.1