題意:python
try: while True: n = input(); n = int(n); a = []; for i in range(0, n): str = input().split(); a += [[int(str[0]), int(str[1])]]; a = sorted(a, key = lambda x: x[0]+x[1]); sumv = 0; maxx = 0; for i in range(0, n): maxx = max(maxx, sumv-a[i][1]); sumv += a[i][0]; print(maxx); except EOFError: pass