Delivery

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Mathew is the owner of a delivery company. He lives in a city where there are exactly 10910^9 houses ordered in a line. Each house has a number, and the house with number ii is adjacent to houses with numbers i1i - 1 and i+1i + 1 (if they exist). Mathew’s company has received NN queries for a delivery at house H_iH\_i at time exactly T_iT\_i. There are no two queries that are at the same time and at the same house. To save money, Mathew wants to know how many delivery trucks he will need to complete all the queries. The trucks he will buy can move 11 house to the left or the right in one unit of time (they can also stay at the same house). In the beginning, the trucks can be parked in front of whichever houses the owner chooses. In addition, the time for delivery is negligible.

Mathew is a busy man and has no time for easy tasks like this one so he asks you to write a program that finds the minimum number of delivery trucks he will need.

입력

From the first line of the standard input, your program should read one integer NN – the number of queries. Each of the next NN lines will contain two integers T_iT\_i and H_iH\_i – the time and house the delivery should happen at.

출력

On a single line, your program should output the minimum number of delivery trucks that are needed.

제한

  • 1N1061 ≤ N ≤ 10^6
  • 1T_i,H_i1091 ≤ T\_i, H\_i ≤ 10^9
  • T_iT_jT\_i \ne T\_j or H_iH_jH\_i \ne H\_j for iji \ne j

힌트

The minimum number of delivery trucks we need is 2. One way to complete all deliveries is:

  • First truck: (1, 1)* → (2, 1) → (3, 1) → (4, 1)* → (5, 1)
  • Second truck: (1, 2) → (2, 3)* → (3, 2)* → (4, 3)* → (5, 4)*

Where (tt, hh) represents the truck being at house hh at time tt, and * are times on which the truck makes a delivery.