# 雷达安装

Main.java

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

static int n,d;
static boolean flag;
static Node node[];

public static void main(String[] args) {

Scanner in = new Scanner(System.in);
int x,y;
n = in.nextInt();
d = in.nextInt();
if(n==0 && d==0)return;
flag = true;
node = new Node[n];
for(int i=0;i<n;i++) {
x = in.nextInt();
y = in.nextInt();
if(y>d)flag = false;
else
node[i] = new Node(x - Math.sqrt(d*d - y*y), x + Math.sqrt(d*d - y*y));
}
//按左端点排序
Comparator<Node>comparator = new MyComparator();
Arrays.sort(node,comparator);

if(flag)System.out.println(solve());
else System.out.println("-1");
in.close();
}

public static int solve() {
int ans;double now;
ans = 1;now = node[0].getRight();
//若当前线段与目前集合中的线段没有公共点，则新加入一个雷达
for(int i=1;i<n;i++) {
if(node[i].getLeft()<=now)  //如果左端点的值小于等于now，则不需要新加雷达
now = Math.min(now, node[i].getRight());
else {//如果大于,说明该区间与之前的区间不存在公共部分,则需要新加雷达
++ans;
now = node[i].getRight();
}
}
return ans;
}
}

class MyComparator implements Comparator<Node>{

public int compare(Node o1, Node o2) {     //升序
if(o1.getLeft() > o2.getLeft())
return 1;
else if(o1.getLeft() == o2.getLeft())
return 0;
else return -1;
}
}


Node.java

 public class Node {

private double left;
private double right;

public Node(double left,double right){
this.left = left;
this.right = right;
}

public double getLeft() {
return left;
}

public void setLeft(double left) {
this.left = left;
}

public double getRight() {
return right;
}

public void setRight(double right) {
this.right = right;
}
}