Bus Assignment
InterviewTime limit2sMemory limit2048 MB
Given how many people get off and get on at each stop, find the maximum number of passengers on the bus at any one time.
- Level
Easy2 of 10
- Topics
- Simulation, Array
- Solved
- No attempts yet
Statement
The Institution for Carrying People Carefully manages the famous Line Bus in Line Town. The Line Bus passes through stops numbered from to . At stop , people get off the bus first, and then people get on. The bus starts empty at stop , visits the stops in increasing order, and empties at stop .
A passenger on the Line Bus must have a seat. A bus with capacity has exactly seats for passengers, and each rider occupies one seat. The driver is not counted. The institution wants the minimum capacity needed to run the Line Bus.
Input
The first line contains an integer ().
Each of the next lines contains two integers and (). At least one person boards the bus, the total number of boarding people over all stops is at most , and the bus is empty after stop .
Output
Print a single integer, the minimum capacity of the bus.