HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


50958 - Number of Passengers in Train

Section problems

• 50960 - Number of Heart Beats
• 50885 - Calculate the Average
• 51108 - First Unique Character
• 50887 - Average of Test Scores
• 50904 - Print All Prime Numbers
• 50895 - Hours Minutes and Seconds
• 50902 - Translate Score into Grade
• 50938 - Translate Score into Grade
• 50958 - Number of Passengers ...
• 50890 - Convert Celsius to Fahrenheit
• 50889 - Convert to Minutes and Sec...
• 50952 - Print All Numbers from N d...
• 50900 - Put the Numbers in Descend...
• 50884 - Area and Perimeter Of The ...
• 50899 - How Many Years
• 50610 - Feasibility
• 50612 - Fun game

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.

Number of Passengers in Train

A train leaves the first station with N passengers and visits K stations before it arrives at the last station.

In each station some passengers got off the train and some passengers got on the train. Everybody in the train got off at the last station.

 

Make a program that calculates how many passengers got off the train at the last station.

 

Input:

The first line of the input has two integers K and N.

Each of the following K lines contains two integers, the first one denotes the number of passengers who got off the train at that station, and the second one denotes the number of passengers got on the train at that station.

 

Output:

The output should have a single integer that is number of passengers who got off the train at the last station.

Sample Input1:

Sample Input2:

2 5

3 6

2 4

5 20

6 15

5 30

20 12

15 8

6 7

Sample Output1:

Sample Output2:

10

40

 

Для отправки решений необходимо выполнить вход.

www.contester.ru