Bus Assignment

시간 제한2초메모리 제한2048 MB

요약
정류장마다 내리는 사람과 타는 사람 수가 주어질 때, 승객이 서 있지 않도록 하는 최소 버스 정원을 구한다.
난이도

쉬움10점 중 2점

유형
시뮬레이션, 구현, 누적 합
정답자
아직 제출이 없습니다

문제

The Institution for Carrying People Carefully is responsible for managing the famous Line Bus in Line Town. The Line Bus goes through nn stops conveniently numbered from 11 to nn. At stop ii, a_ia\_i people first get off the bus. Then, b_ib\_i people get on the bus. The bus starts out empty at stop 11 and then goes through the stops in numerically increasing order, eventually stopping at stop nn where the bus empties.

When someone rides the Line Bus, they must be seated. A bus with capacity cc has exactly cc seats for passengers. Each rider of the Line Bus occupies exactly one seat. The driver of the Line Bus is not counted. The Institution for Carrying People Carefully wants to know what is the minimum capacity bus needed to run the Line Bus.

입력

The first line contains a single integer, nn (2≤n≤2⋅105)(2 \le n \le 2 \cdot 10^5).

Each of the next nn lines contains two integers, a_ia\_i and b_ib\_i (0≤a_i,b_i≤109)(0 \le a\_i, b\_i \le 10^9). It is guaranteed that at least one person boards the bus, at most 10910^9 people board the bus over all stops, and that the bus will empty at stop nn.

출력

Output a single integer, the minimum capacity bus needed to run the Line Bus.

예제1

  1. 예제 1

    입력
    4
    0 3
    1 2
    2 1
    3 0
    
    예상 출력
    4