about summary refs log tree commit diff
path: root/others/volume1/020.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-11 11:37:48 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-11 11:37:48 +0700
commitdf9a0d140a7b7edef66f95aa13b5bb4488147f68 (patch)
treede213e8e6abf244426fcec5974c1cc247897f869 /others/volume1/020.pas
parent092019121ad5ef6f82cd8fe7bf6ee143fce9648d (diff)
downloadcp-df9a0d140a7b7edef66f95aa13b5bb4488147f68.tar.gz
Fast and furiously add others/volume1
Diffstat (limited to 'others/volume1/020.pas')
-rw-r--r--others/volume1/020.pas32
1 files changed, 32 insertions, 0 deletions
diff --git a/others/volume1/020.pas b/others/volume1/020.pas
new file mode 100644
index 0000000..4d11bd2
--- /dev/null
+++ b/others/volume1/020.pas
@@ -0,0 +1,32 @@
+var
+  n, max, l, h, l0, h0: smallint;
+  a: array of int64;
+
+begin
+  readln(n);
+  setlength(a, n + 1);
+  for l := 0 to n - 1 do
+    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
+        begin
+          if max < h0 - l0 then
+            begin
+              max := h0 - l0;
+              l := l0;
+              h := h0
+            end;
+          l0 := h0 + 1;
+          break
+        end;
+
+  writeln(l + 1, ' ', h + 1)
+end.
+end.