QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21365. Mucche affollate

Statistics

Le $N$ mucche di Farmer John $(1 \le N \le 50,000)$ pascolano lungo una recinzione unidimensionale. La mucca $i$ si trova in $x(i)$ ed è alta $h(i)$ ($1 \le x(i),h(i) \le 10^9$).

Una mucca si sente «affollata» se a sinistra, entro distanza $D$, c’è un’altra mucca alta almeno il doppio di lei, e anche a destra, entro distanza $D$, c’è una mucca simile ($(1 \le D \le 1,000,000,000)$). Queste mucche producono meno latte, quindi Farmer John vuole contarle. Aiutalo.

Input

  • Riga 1: due interi $N$ e $D$.
  • Righe $2..1+N$: la riga $i+1$ contiene gli interi $x(i)$ e $h(i)$. Le posizioni delle $N$ mucche sono distinte.

Output

  • Riga 1: numero di mucche affollate.

Esempi

Input 1

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

Output 1

2

Nota

Ci sono 6 mucche e la soglia di distanza per sentirsi affollate è 4. La mucca n.1 è in $x=10$ e ha altezza $h=3,$, e così via.

Le mucche in $x=5$ e $x=6$ sono entrambe affollate.

Autore del problema: Brian Dean, 2013

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.