QOJ.ac

QOJ

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

#21365. أبقار مزدحمة

Statistics

ترعى أبقار Farmer John وعددها $N$ $(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.