13 lines
252 B
Python
13 lines
252 B
Python
|
# Accepted #
|
||
|
n = int(input())
|
||
|
discos = [tuple(map(int, input().split())) for _ in range(n)]
|
||
|
|
||
|
discos.sort(key=lambda x:(-x[1],x[0]))
|
||
|
|
||
|
discount = 0
|
||
|
balance = 0
|
||
|
for price, nxt in discos:
|
||
|
balance -= price - discount
|
||
|
discount += nxt
|
||
|
|
||
|
print(-balance)
|