Advertisement
Farz0l1x

Untitled

Dec 18th, 2023
907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. file = open('input.txt')
  2. A = list(map(int, file.readlines()))
  3. A = A[1:]
  4. a0_23 = []
  5. a1_23 = []
  6. a0 = []
  7. a1 = []
  8. n = len(A)
  9. for i in range(n):
  10.     x = A[i]
  11.     if x % 2 == 0 and x % 23 == 0:
  12.         a0_23 += [x]
  13.     elif x % 2 != 0 and x % 23 == 0:
  14.         a1_23 += [x]
  15.     elif x % 2 == 0 and x % 23 != 0:
  16.         a0 += [x]
  17.     elif x % 2 != 0 and x % 23 != 0:
  18.         a1 += [x]
  19. a0_23.sort()
  20. a1_23.sort()
  21. a0.sort()
  22. a1.sort()
  23. print(max(a0[-1] + a0_23[-1], a1[-1] + a1_23[-1], a0_23[-1] + a0_23[-2], a1_23[-1] + a1_23[-2]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement