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 + 1, len(A)):
- if (A[i] + A[j]) % 350 == 0 and A[i] > A[j]:
- Max = max(Max, A[i] + A[j])
- print(Max)
- m = [-10**20] * 350
- ans = -10**20
- for i in range(len(A)):
- x = A[i]
- ost = 0 if x % 350 == 0 else 350 - x % 350
- if m[ost] > x:
- ans = max(ans, x + m[ost])
- m[x % 350] = max(m[x % 350], x)
- print(ans)
Advertisement
Add Comment
Please, Sign In to add comment