Guest User

Untitled

a guest
Jun 15th, 2015
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. N = int(input())
  2. s = 8
  3. buf = [1000]*s
  4. buf_even = [1000]*s
  5. result = 1001*1001
  6. n = int(input())
  7. if n % 2 == 0:
  8.     buf_even[0] = n
  9. buf[0] = n
  10. for i in range(1, s):
  11.     n = int(input())
  12.     if n % 2 == 0:
  13.         buf_even[i] = min(buf_even[i-1], n)
  14.     else:
  15.         buf_even[i] = buf_even[i-1]
  16.     buf[i] = min(buf[i-1], n)
  17. for i in range(s, N):
  18.     n = int(input())
  19.     if n % 2 == 0:
  20.         result = min(n * buf[i % s], result)
  21.         buf_even[i % s] = min(n, buf[(i-1) % s])
  22.     else:
  23.         result = min(n * buf_even[i % s], result)
  24.     buf[i % s] = min(n, buf[(i-1) % s])
  25. if result != 1001*1001: print(result)
  26. else: print(-1)
Advertisement
Add Comment
Please, Sign In to add comment