Data Checker
InterviewTime limit1sMemory limit1024 MB
Given N circles centered on the x-axis, decide whether every pair is either disjoint or nested, so no two circles intersect.
Problem
You have created the problem "Moving Circles 2", and now you must write code that checks whether the data you made satisfies the conditions of that problem.
The data for that problem must satisfy the following conditions.
- The center of every circle must lie on the -axis.
- When any two of the circles are chosen, they must not have an intersection point. That is, one circle lies inside the other or outside it.
The data format gives only the number of circles , the -coordinate of each circle's center, and the radius of each circle. Therefore, you only need to check whether condition 2 is satisfied.
Check whether the given data satisfies these conditions.
Input
The first line gives the number of circles .
From the second line to the -th line, the -coordinate of a circle's center and the radius of the circle are given, separated by a space.
Output
If the data satisfies the conditions, print YES. Otherwise, print NO.
Constraints
- are integers
Hints
Relative position of two circles
Use the following to determine the relative position of two circles.
Let the radius of circle A be , the radius of circle B be , and the distance between the centers of circles A and B be .
Distance between two points
The formula for the distance between and is as follows.