G. [USACO13NOV] Crowded Cows S

    远端评测题 1000ms 125MiB

[USACO13NOV] Crowded Cows S

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

题目描述

Farmer John's NN cows (1N50,0001 \le N \le 50,000) are grazing along a one-dimensional fence. Cow ii is standing at location xix_i and has height hih_i (1xi,hi1,000,000,0001 \le x_i,h_i \le 1,000,000,000).

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

输入格式

  • Line 11: Two integers, NN and DD.

  • Lines 2..1+N2..1+N: Line i+1i+1 contains the integers xix_i and hih_i. The locations of all NN cows are distinct.

输出格式

  • Line 11: The number of crowded cows.
6 4 
10 3 
6 2 
5 3 
9 7 
3 6 
11 2 

2 

提示

There are 66 cows, with a distance threshold of 44 for feeling crowded. Cow #1 lives at position x=10x=10 and has height h=3h=3, and so on.

The cows at positions x=5x=5 and x=6x=6 are both crowded.

B班基础数据结构

未认领
状态
已结束
题目
9
开始时间
2026-3-10 18:00
截止时间
2026-3-18 23:59
可延期
24 小时