Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n = int(input())
- res = 0
- c0 = 0
- c1 = 0
- o1 = o2 = e1 = e2 = 20001
- for i in range(0, n):
- a, b = map(int, input().split())
- if a>b:
- res+=a
- else:
- res+=b
- if abs(a-b) % 2 == 0:
- if abs(a-b) < o1:
- o2 = o1
- o1 = abs(a-b)
- elif abs(a-b) < o2:
- o2 = abs(a-b)
- else:
- if abs(a-b) < e1:
- e2 = e1
- e1 = abs(a-b)
- elif abs(a-b) < e2:
- e2 = abs(a-b)
- if res % 2 == 0:
- if c1 > c0:
- print(res)
- else:
- if res-o1>res-e1-e2:
- print(res-o1)
- else:
- print(res-e1-e2)
- else:
- if c0>c1:
- print(res)
- else:
- if res-e1>res-o1-o2:
- print(res-e1)
- else:
- print(res-o1-o2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement