Bus Route


Submit solution

Points: 2 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Bus 90 routinely runs along Leslie. For example, it is used by STR students to get to school each day.
As it runs along, it passes through \(N\) bus stops. Initially, the bus contains \(0\) people.

At bus stop \(i\) (\(1 \le i \le N\)), two things occur:

  1. \(a_i\) people get on the bus.
  2. \(b_i\) people get off the bus.

Please write a program that tells us how many people are on the bus after visiting each stop \(i\).

Input Specification

The first line will contain the integer \(N\) (\(1 \le N \le 10^5\)), the number of bus stops.
The next \(N\) lines will contain \(a_i\) and \(b_i\) (\(1 \le i \le N\)), representing how many people board and leave the bus on stop \(i\), respectively.

Output Specification

Print \(N\) lines, with line \(i\) (\(1 \le i \le N\)) telling how many people are on the bus after stop \(i\).

Sample Input

3 
2 0
3 1
4 2

Sample Output

2
4
6

We can simulate the number of people.
At stop \(1\): \(2\) people board and \(0\) people leave. # people: \(2\)
At stop \(2\): \(3\) people board and \(1\) people leave. # people: \(4\)
At stop \(3\): \(4\) people board and \(2\) people leave. # people: \(6\)


Comments

There are no comments at the moment.