J - Vaccination Against Corona


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Whenever a baby is born in Neverland, a place on the main road of Neverland is assigned to her/him. In every traditional activity, such as morning exercises, the citizens of Neverland take place on their own assigned place on the main road. Unfortunately, during the corona pandemic, all out-door traditional activities of Neverland are canceled. After the approval of the corona vaccine, Neverland’s council has decided to reopen the activities, but of course with a corona-secure regulation. Neverland’s council has assumed that a vaccinated person is safe both in getting infected or in the transmission of the infection. On the other hand for non-vaccinated persons, there is a corona-safe distance that keeping this distance between every two persons keeps them safe. Thus, a safe situation is a situation in which every two non-vaccinated persons keep the corona-safe physical distance. Knowing assigned places to the citizens participating in traditional activities, Neveland’s council has decided to vaccinate a minimum number of citizens to make their activity safe.

ورودی🔗

The input consists of two lines. The first line contains two integers separated by a space nn (11nn10510^5), the number of Neverland’s citizens participating in the activities, and the corona-safe distance LL (11LL10510^5), i.e. two persons will not get the virus from each other if their distance is at least L. The next line consists of n integer numbers in the range [105,105][10^5,10^5], where the ithi-th number represents the location of the ithi-th participating citizen. The location is calculated as the distance in meters from the beginning of the main road of Neverland.

خروجی🔗

Print the minimum number of citizens that should be vaccinated to have a safe activity in Neverland.

مثال🔗

ورودی نمونه ۱🔗

5 2
-1 0 1 2 3
Plain text

خروجی نمونه ۱🔗

2
Plain text

ورودی نمونه ۲🔗

5 4
1 2 4 6 8
Plain text

خروجی نمونه ۲🔗

3
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.