AtCoder Beginner Contest 101
C
Minimization
AtCoder
⌀ 579
原题
← BD →
翻译中…

Problem Statement

翻译中…

There is a sequence of length $N$: $A_1, A_2, ..., A_N$. Initially, this sequence is a permutation of $1, 2, ..., N$.

翻译中…

On this sequence, Snuke can perform the following operation:

翻译中…
  • Choose $K$ consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.
翻译中…

Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times. Find the minimum number of operations required. It can be proved that, Under the constraints of this problem, this objective is always achievable.

翻译中…

Constraints

翻译中…
  • $2 \leq K \leq N \leq 100000$
  • $A_1, A_2, ..., A_N$ is a permutation of $1, 2, ..., N$.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
A_1 A_2 ... A_N

翻译中…

Output

翻译中…

Print the minimum number of operations required.

翻译中…

样例

Input #1
4 3
2 3 1 4
Output #1
2
One optimal strategy is as follows: - In the first operation, choose the first, second and third elements. The sequence $A$ becomes $1, 1, 1, 4$. - In the second operation, choose the second, third and fourth elements. The sequence $A$ becomes $1, 1, 1, 1$.
Input #2
3 3
1 2 3
Output #2
1
Input #3
8 3
7 3 1 8 4 6 2 5
Output #3
4
题目信息
题号
arc099_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。