You want to create a network range in a rectangular field of the length \(L\) and breadth \(B\) respectively. The field is symmetrical to the X-axis. The coordinates of the corners of the field are:
Now, you have installed total \(N\) towers at different locations on the X-axis and each tower has the network range of a radius \(R\). You want to determine the minimum number of towers to be installed such that the whole field has the network coverage. If it is not possible for the towers to provide complete network coverage to the whole field, then print \(-1\).
Input format
- First line: \(T\) (number of test cases)
- Second line: Two space-separated integers \(L\) and \(B\)
- Third line: \(N\) (number of towers installed)
- \(N\) lines: follow, with ith of these lines containing two space-separated integers :
- \(X[i]\) is the x-coordinate of the point where the \(i^{th}\) tower is present
- \(R[i]\) is the radius of the network range of the \(i^{th}\) tower
Output format
Print a single integer representing the minimum number of towers to be installed to provide the network coverage to the whole field. If the answer does not exist, then print \(-1\).
Constraints
\(1 \le T \le 20 \)
\(1 \le B < L \le 10^9\)
\(1 \le N \le 10^5 \)
\(0 \le X[i] \le 10^9 \)
\(0 \le R[i] \le 10^9 \)
1 20 6 4 1 5 8 5 13 5 20 5
4
In the sample , it can be clearly seen that all the four towers are required to be powered to provide network coverage to whole rectangular field.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor