QOJ.ac

QOJ

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

#20969. ריחוק חברתי II

Statistics

לאחר התפרצות מחלת הבקר המדבקת מאוד COWVID-19, Farmer John חושש לבריאות פרותיו.

למרות ניסיונותיו לגרום ל-$N$ פרותיו ($1 \leq N \leq 1000$) לשמור על ״ריחוק חברתי״, רבות נדבקו. הן ממוספרות $1 \ldots N$ וניצבות בנקודות שונות לאורך דרך ארוכה, למעשה ציר מספרים חד-ממדי; פרה $i$ במיקום $x_i$. קיים רדיוס $R$ כך שכל פרה במרחק עד $R$, כולל, מפרה נגועה נדבקת גם היא, ואז מדביקה אחרות במרחק עד $R$ ממנה, וכן הלאה.

הוא אינו יודע את $R$ בדיוק, אבל יודע אילו פרות נגועות. מצאו את המספר המזערי האפשרי של פרות שנדבקו בתחילה.

קלט

השורה הראשונה מכילה $N$. כל אחת מ-$N$ השורות הבאות מתארת פרה בשלמים $x$, $s$: מיקום $x$ ($0 \leq x \leq 10^6$), ו-$s=0$ לבריאה או $s=1$ לחולה. לפחות אחת חולה, וכל הפרות שיכלו לחלות כתוצאה מההתפשטות כבר חולות.

פלט

הדפיסו את מספר הפרות המזערי שיכלו להיות חולות לפני כל התפשטות.

דוגמאות

קלט 1

6
7 1
1 1
15 1
3 1
10 0
6 1

פלט 1

3

הסבר

כאן $R<3$, אחרת הפרה ב-$7$ הייתה מדביקה את זו ב-$10$. לכן לפחות $3$ היו חולות בתחילה: אחת מהשתיים ב-$1$ ו-$3$, אחת מהשתיים ב-$6$ ו-$7$, והפרה ב-$15$.

מחבר הבעיה: Brian Dean

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.