QOJ.ac

QOJ

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

#22673. Romeo と Juliet の逢瀬

Statistics

Farmer John の Moontagues と Cowpulets は敵対しています。Moontague の雄牛 Romeo は Cowpulet の Juliet に恋し、他の Cowpulets に知られず会いたいのです。

柵沿いでできるだけ広く会って草を食べたいのですが、Cowpulets が多すぎると見つかりやすくなります。Romeo は $N$ 頭($1 \le N \le 1000$)の位置を知っています。長い直線の柵は等間隔の $P$ 本の柱($1 \le P \le 1000$)、番号 $1\ldots P$ を持ち、各頭は隣接柱間で食べます。高々 $C$ 頭($0 \le C \le 1000$)を含む最大連続領域の長さを求めてください。

入力

  • 第 $1$ 行:区切られた整数 $N$、$P$、$C$。

  • 第 $2\ldots N+1$ 行:整数 $X$($1\ldots P-1$)は柱 $X$、$X+1$ 間の Cowpulet を表します。同じ柱間に複数いてもかまいません。

出力

  • 第 $1$ 行:高々 $C$ 頭を含む最大連続領域の、柱間の隙間数を表す整数。

入出力例

入力 1

2 6 1
2
3

出力 1

3

注記

6 本の柱 $1,2,3,4,5,6$ があり、2 頭は $2$、$3$ 間と $3$、$4$ 間です。

柱 $3$ から $6$ の長さ $3$ の区間には 1 頭だけです。

問題 8:Romeo と Juliet の逢瀬 [???, 26/0]

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.