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$。Farmer John 知道存在半径 $R$,使得距感染牛至多 $R$ 单位(含边界)的牛也会感染,随后传染给距离自己至多 $R$ 单位的其他牛,如此继续。

不幸的是,Farmer John 不知道 $R$ 的确切值。但他知道哪些牛已经感染。根据这些信息,求最初感染的牛的数量的最小可能值。

输入格式

输入第一行包含 $N$。接下来 $N$ 行每行以两个整数 $x$、$s$ 描述一头牛:$x$ 为位置($0 \leq x \leq 10^6$),健康牛的 $s$ 为 $0$,病牛为 $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.