Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- max = 0
- r = 1000
- n = int(input())
- for i in range(n):
- ab = str(input())
- a = int(ab.split(" ")[0])
- b = int(ab.split(" ")[1])
- if a > b:
- max += a
- if a-b < r and (a-b) % 3 > 0:
- r = a - b
- else:
- max += b
- if b-a < r and(b-a) % 3 > 0:
- r = b - a
- if max % 3 == 0:
- print(str(max-r))
- else:
- print(str(max))
Add Comment
Please, Sign In to add comment