Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- A = [randint(1, 1000) for i in range(1000)]
- Max = 0
- for i in range(len(A)):
- for j in range(i + 11, len(A)):
- if (A[i] + A[j]) % (2 * 567) == 0:
- Max = max(Max, A[i] + A[j])
- print(Max)
- m = [-10**10] * (567 * 2)
- ans = -10**10
- q = A[:10]
- for i in range(10, len(A)):
- x = A[i]
- ost = 0 if x % (567 * 2) == 0 else (567 * 2) - x % (567 * 2)
- ans = max(ans, x + m[ost])
- m[q[0] % (567 * 2)] = max(m[q[0] % (567 * 2)], q[0])
- q.append(x)
- q.pop(0)
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment