QOJ.ac

QOJ

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

#21365. Bedrängte Kühe

Statistics

Farmer Johns $N$ Kühe $(1 \le N \le 50,000)$ grasen entlang eines eindimensionalen Zauns. Kuh $i$ steht an Position $x(i)$ und hat die Höhe $h(i)$ ($1 \le x(i),h(i) \le 10^9$).

Eine Kuh fühlt sich „bedrängt“, wenn links von ihr in einer Entfernung von höchstens $D$ eine andere Kuh mindestens doppelt so hoch ist und rechts von ihr in höchstens $D$ Entfernung ebenfalls eine solche Kuh steht ($(1 \le D \le 1,000,000,000)$). Da bedrängte Kühe weniger Milch geben, möchte Farmer John sie zählen. Hilf ihm.

Eingabe

  • Zeile 1: zwei ganze Zahlen $N$ und $D$.
  • Zeilen $2..1+N$: Zeile $i+1$ enthält die ganzen Zahlen $x(i)$ und $h(i)$. Alle $N$ Kühe haben verschiedene Positionen.

Ausgabe

  • Zeile 1: Anzahl der bedrängten Kühe.

Beispiele

Eingabe 1

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

Ausgabe 1

2

Hinweis

Es gibt 6 Kühe, mit einer Entfernungsschwelle von 4 für das Gefühl der Bedrängtheit. Kuh Nr.1 steht bei $x=10$ und hat Höhe $h=3,$, und so weiter.

Die Kühe bei $x=5$ und $x=6$ sind beide bedrängt.

Aufgabenautor: 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.