# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538257 | 2022-03-16T12:45:54 Z | tkwiatkowski | Art Exhibition (JOI18_art) | C++17 | 0 ms | 0 KB |
def solve(): n = int(input()) artworks = [] for i in range(n): artworks.append(list(map(int, input().split()))) artworks.sort() maxx = -10**18 ans = 0 pref = 0 for a, b in artworks: maxx = max(a - pref, maxx) pref += b ans = max(maxx + pref - a, ans) print(ans) solve()