QOJ.ac

QOJ

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

#21365. פרות צפופות

Statistics

$N$ הפרות של Farmer John $(1 \le N \le 50,000)$ רועות לאורך גדר חד־ממדית. הפרה $i$ עומדת במיקום $x(i)$ וגובהה $h(i)$ ($1 \le x(i),h(i) \le 10^9$).

פרה מרגישה «צפופה» אם משמאלה במרחק של לכל היותר $D$ יש פרה אחרת שגובהה לפחות פי שניים משלה, וגם מימינה במרחק של לכל היותר $D$ יש פרה כזאת ($(1 \le D \le 1,000,000,000)$). פרות צפופות נותנות פחות חלב, ולכן Farmer John רוצה לספור אותן. עזרו לו.

קלט

  • שורה 1: שני שלמים $N$ ו־$D$.
  • שורות $2..1+N$: שורה $i+1$ מכילה את השלמים $x(i)$ ו־$h(i)$. המיקומים של כל $N$ הפרות שונים.

פלט

  • שורה 1: מספר הפרות הצפופות.

דוגמאות

קלט 1

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

פלט 1

2

הערה

יש 6 פרות, עם סף מרחק 4 לתחושת צפיפות. פרה מס׳1 נמצאת ב־$x=10$ וגובהה $h=3,$, וכן הלאה.

הפרות ב־$x=5$ וב־$x=6$ שתיהן צפופות.

מחבר הבעיה: 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.