QOJ.ac

QOJ

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

#21365. Stłoczone krowy

Statistics

$N$ krów Farmer John $(1 \le N \le 50,000)$ pasie się wzdłuż jednowymiarowego ogrodzenia. Krowa $i$ stoi w położeniu $x(i)$ i ma wysokość $h(i)$ ($1 \le x(i),h(i) \le 10^9$).

Krowa czuje się „stłoczona”, jeśli po lewej w odległości co najwyżej $D$ jest inna krowa przynajmniej dwa razy wyższa, a po prawej w odległości co najwyżej $D$ też jest taka krowa ($(1 \le D \le 1,000,000,000)$). Ponieważ stłoczone krowy dają mniej mleka, Farmer John chce je policzyć. Pomóż mu.

Wejście

  • Wiersz 1: dwie liczby całkowite $N$ i $D$.
  • Wiersze $2..1+N$: wiersz $i+1$ zawiera liczby całkowite $x(i)$ i $h(i)$. Położenia wszystkich $N$ krów są różne.

Wyjście

  • Wiersz 1: liczba stłoczonych krów.

Przykład

Wejście 1

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

Wyjście 1

2

Uwagi

Jest 6 krów, a próg odległości dla stłoczenia wynosi 4. Krowa nr1 jest w $x=10$ i ma wysokość $h=3,$, i tak dalej.

Krowy w $x=5$ i $x=6$ są obie stłoczone.

Autor zadania: 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.