Farz0l1x

Untitled

Jun 3rd, 2023
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. from random import randint
  2. A = [randint(1, 1000) for i in range(1000)]
  3. Max = 0
  4. for i in range(len(A)):
  5. for j in range(i + 1, len(A)):
  6. if (A[i] + A[j]) % 350 == 0 and A[i] > A[j]:
  7. Max = max(Max, A[i] + A[j])
  8. print(Max)
  9.  
  10. m = [-10**20] * 350
  11. ans = -10**20
  12. for i in range(len(A)):
  13. x = A[i]
  14. ost = 0 if x % 350 == 0 else 350 - x % 350
  15. if m[ost] > x:
  16. ans = max(ans, x + m[ost])
  17. m[x % 350] = max(m[x % 350], x)
  18. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment