Guest User

Untitled

a guest
May 28th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. max = 0
  2. r = 1000
  3. n = int(input())
  4. for i in range(n):
  5.     ab = str(input())
  6.     a = int(ab.split(" ")[0])
  7.     b = int(ab.split(" ")[1])
  8.     if a > b:
  9.         max += a
  10.         if a-b < r and (a-b) % 3 > 0:
  11.             r = a - b
  12.     else:
  13.         max += b
  14.         if b-a < r and(b-a) % 3 > 0:
  15.             r = b - a
  16. if max % 3 == 0:
  17.     print(str(max-r))
  18. else:
  19.     print(str(max))
Add Comment
Please, Sign In to add comment