Parking Ships
Time limit1sMemory limit128 MB
The captain's parking interval is fixed; place the other ships on a line so that as many ship intervals as possible cover their house centers.
Problem
Captain Blackbeard and his pirates have each bought a house on their favorite island. The houses stand in a single row along the beach, and next to his house every pirate also buys a ship. One long pier runs along the beach, and that is where the ships are parked.
There is enough room on the pier for every ship, but not every pirate can park directly in front of his own house. A pirate is happy only if some part of his parking space lies in front of the center of his house.
Formally, the parking space of pirate is a real interval (with ) that is long enough to hold his ship, i.e. , where is the length of ship . Pirate is happy exactly when , where is the center of his house. The parking spaces of different pirates must be interior-disjoint (their endpoints may touch).
The captain (pirate ) insists on the best spot for himself: he takes the parking space in which the center of his ship coincides with the center of his house, namely . With that choice fixed, he wants to make as many pirates as possible happy. Compute that maximum.
Input
The first line contains a single integer: the number of test cases. Each test case has the following format:
- One line with an integer (): the number of pirates, including the captain.
- lines follow; the -th of them contains two integers () and (): the center of the house and the length of the ship of pirate . The first pirate listed is always the captain.
Output
For each test case, print a single line with one integer: the maximum number of happy pirates under an optimal assignment of parking spaces. This count includes the captain. You may assume the pier extends without bound in both directions.