zhukov000

27A

Jun 24th, 2021
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. import sys
  2. with open("27a.txt") as file:
  3.     sys.stdin = file
  4.     M = 71
  5.     n = int(input())
  6.     a = [ int(input()) for i in range(n) ]
  7.  
  8.     def solve():
  9.       mxs = 0 # макс. сумма
  10.       ans = 0 # длинна
  11.       for i in range(n):
  12.         s = 0
  13.         for j in range(i, n):
  14.           s += a[j]
  15.           if s % M == 0 and (s > mxs or (s == mxs and j - i + 1 < ans)):
  16.             mxs = s
  17.             ans = j - i + 1
  18.       print(ans)
  19.  
  20.     solve()
  21.  
Advertisement
Add Comment
Please, Sign In to add comment