Farz0l1x

Untitled

Dec 2nd, 2023
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. file = open('15A.txt')
  2. A = list(map(int, file.readlines()))
  3. Max = -10**9
  4. for i in range(len(A)):
  5.     for j in range(i + 1, len(A)):
  6.         if abs(A[i] - A[j]) % 80 == 0:
  7.             Max = max(Max, A[i] - A[j])
  8. print(Max)
  9.  
  10. file = open('15B.txt')
  11. A = list(map(int, file.readlines()))
  12. a = [[] for i in range(80)]
  13. for i in range(len(A)):
  14.     ost = A[i] % 80
  15.     a[ost] += [A[i]]
  16. b = []
  17. for i in range(80):
  18.     a[i].sort()
  19.     b += a[i][-1:]
  20.     b += a[i][:1]
  21. ans = []
  22. for i in range(len(b)):
  23.     for j in range(i + 1, len(b)):
  24.         if abs(b[i] - b[j]) % 80 == 0:
  25.             ans  += [b[i] - b[j]]
  26. print(max(ans))
Advertisement
Add Comment
Please, Sign In to add comment