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$ の牛は、長い道(実質的に 1 次元の数直線)の異なる位置に立ち、牛 $i$ は $x_i$ にいます。感染牛から距離 $R$ 以下(境界を含む)の牛も感染し、さらに自分から $R$ 以下の牛に感染を広げる、という半径 $R$ が存在すると知っています。

残念ながら正確な $R$ は分かりませんが、感染した牛は分かります。この情報から、最初に感染していた牛の最小の可能数を求めてください。

入力

最初の行に $N$ が与えられます。次の $N$ 行は牛ごとの整数 $x$、$s$ で、位置は $x$($0 \leq x \leq 10^6$)、健康なら $s=0$、病気なら $s=1$ です。少なくとも 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.