/ GCOJ / 题库 /

[USACO13NOV] Crowded Cows S

[USACO13NOV] Crowded Cows S

题目描述

Farmer John's \(N\) cows \((1 \leq N \leq 50,000)\) are grazing along a one-dimensional fence. Cow \(i\) is standing at location \(x_i\) and has height \(h_i\) \((1 \leq x_i,h_i \leq 10^9)\).

A cow feels "crowded" if there is another cow at least twice her height within distance \(D\) on her left, and also another cow at least twice her height within distance \(D\) on her right \((1 \leq D \leq 10^9)\). Since crowded cows produce less milk, Farmer John would like to count the number of such cows. Please help him.

输入格式

  • Line \(1\): Two integers, \(N\) and \(D\).
  • Lines \(2\) to \(1+N\): Line \(i+1\) contains the integers \(x_i\) and \(h_i\). The locations of all \(N\) cows are distinct.

输出格式

  • Line \(1\): The number of crowded cows.

输入输出样例

输入 #1

6 4
10 3
6 2
5 3
9 7
3 6
11 2

输出 #1

2

信息

ID
1024
难度
6
分类
数据结构 | 单调队列 点击显示
标签
递交数
2
已通过
1
通过率
50%
上传者