Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://inf-ege.sdamgia.ru/problem?id=27424
- data = open('27-B_demo.txt').readlines()
- n = int(data[0])
- sum = 0
- for i in range(1, n + 1):
- x, y = map(int, data[i].split())
- sum += max(x, y)
- if (sum % 3) != 0:
- print(sum)
- exit(0)
- mn = 100000000000
- for i in range(1, n + 1):
- x, y = map(int, data[i].split())
- if (abs(x - y) % 3) != 0: #max(x, y) - min(x, y)
- mn = min(mn, abs(x - y))
- print(sum - mn)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement