Bus Assignment
시간 제한2초메모리 제한2048 MB
정류장마다 내리는 사람과 타는 사람 수가 주어질 때, 승객이 서 있지 않도록 하는 최소 버스 정원을 구한다.
문제
The Institution for Carrying People Carefully is responsible for managing the famous Line Bus in Line Town. The Line Bus goes through stops conveniently numbered from to . At stop , people first get off the bus. Then, people get on the bus. The bus starts out empty at stop and then goes through the stops in numerically increasing order, eventually stopping at stop where the bus empties.
When someone rides the Line Bus, they must be seated. A bus with capacity has exactly 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, .
Each of the next lines contains two integers, and . It is guaranteed that at least one person boards the bus, at most people board the bus over all stops, and that the bus will empty at stop .
출력
Output a single integer, the minimum capacity bus needed to run the Line Bus.