Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f = open('27_A.txt')
- #f = open('tst.txt')
- n = int(f.readline())
- a = [int(i) for i in f.readlines()]
- f.close()
- a = [0] + a
- n += 1
- pf = [0] * n
- for i in range(1, n):
- pf[i] = pf[i-1] + a[i]
- mxs = 0
- ansl = 0
- for i in range(n):
- for j in range(i+1,n):
- nows = pf[j] - pf[i]
- if nows % 43 == 0:
- if nows > mxs:
- mxs = nows
- ansl = j - i
- elif nows == mxs:
- if j - i < ansl:
- ansl = j - i
- print(ansl, mxs)
- print(a)
- print(pf)
- """
- 3 258
- [0, 43, 43, 1, 129, 42, 87]
- [0, 43, 86, 87, 216, 258, 345]
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement