Problem:


Score : 300 points

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.

Sample Input 1

4 3
2 3 1 4

Sample 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.

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4



Sample input:
4 3
2 3 1 4


Sample output:
2

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
flag=0

while N>0:
    N-=(K-1)
    flag+=1
    if N==1:
        break;
print(flag)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = ((N - 1) + ((K - 1) - 1)) // (K - 1)
print(ans)

Submission status: Accepted

Solution code:
N,K= [int(x) for x in input().split()]
print(1+(N-2)//(K-1))

Submission status: Accepted

Solution code:
N,K = map(int, input().strip().split(' '))
A = list(map(int, input().strip().split(' ')))
#min_i = A.index(1)

print((len(A)-1+K-2)//(K-1))

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
if (n-1)%(m-1)==0:
  print((n-1)//(m-1))
else:
  print((n-1)//(m-1)+1)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = (n-1)//(k-1)

if (n-1)%(k-1) == 0:
  print(b)
else:
  print(b+1)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n, k = LI()
a = LI()
print((n - 1) // (k - 1) + bool((n - 1) % (k - 1)))

Submission status: Accepted

Solution code:
import math
n,k = map(int,input().split())

a = list(map(int,input().split()))

ans = math.ceil((n-1)/(k-1))
print(ans)

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

min_a = min(A)
min_a = A.count(min_a)
calc = N - min_a

K -= 1
print(math.ceil(calc/K))

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))

res=(n-2)//(k-1)+1
print(res)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

from math import ceil

N, K = map(int, input().split())
A = list(map(int, input().split()))

# 1〜Nの並び替えなので、最後は必ず1になる

# まず左端までを1に
idx = A.index(1)

# 左の個数
left = ceil(idx / (K-1))
remain = (K-1)*(left-1)+K

# 右の個数
right = ceil((N-remain) / (K-1))

print(left+right)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A = list(map(int,input().split()))
print(-(-(len(A)-1)//(K-1)))

Submission status: Accepted

Solution code:
n, k = [int(x) for x in input().split()]
print((n - 2) // (k - 1) + 1)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = map(int, input().split())

print((n-1+k-2)//(k-1))

Submission status: Accepted

Solution code:
#ABC101C
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
print(((n-1)+(k-1)-1)//(k-1))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = input()

print(((n-1)+(k-2))//(k-1))

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
input()
print(1 + math.ceil((n - k) / (k - 1)))

Submission status: Accepted

Solution code:
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

print(math.ceil((n-k)/(k-1)) + 1)

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))

print(-(-(N-1)//(K-1)))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
a = A.index(1)
b = -(-a//(k-1))*(k-1)
if n == k:
    print(1)
else:
    print(-(-a//(k-1))-(-(n-b-1)//(k-1)))

Submission status: Accepted

Solution code:
import math
N, K = map(int, input().split())
a = list(map(int, input().split()))

tmp = a.index(min(a))
amri = ((tmp) % (K - 1))
if amri == 0:
    ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
else:
    ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - (K- amri)) / (K - 1)) + 1
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
c=1
while K+(c-1)*(K-1)<N:
  c+=1
print(c)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
ans = ((N-1)//(K-1) + (1 if (N-1)%(K-1) else 0))
print(ans)

Submission status: Accepted

Solution code:




def main():

    N,K = map(int,input().split())
    aList = list(map(int,input().split()))

    if N == K : print(1); exit()
    cnt = 1
    rem = len(aList)
    rem -= K
    decrease = K-1

    while(rem > 0):
        rem -= decrease
        cnt += 1
    print(cnt)

 





if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
print(-(-(N - 1) // (K - 1)))

Submission status: Accepted

Solution code:
N, K, *A = map(int, open(0).read().split())
print(-(-(N - 1) // (K - 1)))

Submission status: Accepted

Solution code:
N, K = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

print((N - 1) // (K - 1) + (1 if (N - 1) % (K - 1) else 0))

Submission status: Accepted

Solution code:
N, K = [int(str) for str in input().strip().split()]
A = [int(str) for str in input().strip().split()]

min_index = A.index(min(A))
# ans = min_index // (K - 1) + (N - min_index - 1) // (K - 1)
ans = (N - 1) // (K - 1) + (1 if (N - 1) % (K - 1) else 0)

print(ans)

Submission status: Accepted

Solution code:
import math
def resolve():
    n, k = list(map(int, input().split()))
    aaa = list(map(int, input().split()))
    if k >= n:
        print(1)
    else:
        print(math.ceil((n-1) / (k-1)))
resolve()

Submission status: Accepted

Solution code:
# 全て 1 になる場合しか有り得ない

N, K = map(int, input().split())
As = list(map(int, input().split()))

print((len(As) - 2) // (K-1) + 1)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]

if n==k:
    ans=1
else:
    ans = -(-(n-k)//(k-1))+1

print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
print((n-1)//(k-1)+1 if (n-1)%(k-1) else (n-1)//(k-1))

Submission status: Accepted

Solution code:
import math

n,k = map(int,input().split())
a = list(map(int, input().split()))

n = n - 1
k = k - 1

print(math.ceil(n/k))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())

A = list(map(int,input().split()))
one = 0
for i in range(len(A)):
    if A[i] == 1:
        one = i
        
zenhan = one - 0
kouhan = N-1 - one

if zenhan%(K-1) != 0:
    kouhan -= (K-1 - zenhan%(K-1))

print(-(-zenhan//(K-1)) - (-kouhan//(K-1)))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
MIN_idx = A.index(min(A))
ans = 0
if (N-(MIN_idx+1)) % (K-1) == 0:
    ans += (N-(MIN_idx+1)) // (K-1)
else:
    ans += (N-(MIN_idx+1)) // (K-1) + 1
    MIN_idx -= (K-1) - (N-(MIN_idx+1)) % (K-1)
if MIN_idx % (K-1) == 0:
    ans += MIN_idx // (K-1)
else:
    ans += MIN_idx // (K-1) + 1
print(ans)

Submission status: Accepted

Solution code:
m,n = list(map(int, input().split()))
a = list(map(int, input().split()))
c = len(a)
d = (c-1)//(n-1)
e = (c-1)% (n-1)
print(d if e== 0 else (d+1))

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))

print(math.ceil((N - 1) / (K - 1)))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
r=n-A.index(1)-1
l=A.index(1)
print(min(-(-r//(k-1))-(-l//(k-1)),-(-(n-1)//(k-1))))

Submission status: Accepted

Solution code:
N,K=[int(s) for s in input().split()]
x=1
for i in range(1,N):
  x+=(K-1)
  if x>=N:
    print(i)
    break

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

import math
print(math.ceil((n - 1) / (k - 1)))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

print((n - k - 1) // (k - 1) + 2)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

rmn = n - k
ans = (rmn - 1) // (k - 1) + 2

print(ans)

Submission status: Accepted

Solution code:
# ABC101 C - Minimization
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))

print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
import math
S = list(map(int,input().split()))
N = S[0]
K = S[1]
print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
As = list(map(int, input().split()))
#i = As.index(1)
#r = (i +(K-1)-1)//(K-1)+(N-i-1 +(K-1)-1)//(K-1)
r = (N-1 +(K-1)-1)//(K-1)
print(r)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a
# C - Minimization
import math
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

min_x = min(a_list)
min_x_i_list = [i for i, a in enumerate(a_list) if a == min_x]

c = 0

# 最初のi
start_x_i = min_x_i_list[0]
# 最初に左側を、できるだけ無駄がでないようにして埋める
if start_x_i + 1 < K:
    index = K - 1
    c += 1
else:
    x = math.ceil(start_x_i / (K - 1))
    index = (K - 1) * x
    c += x

while index < N - 1:  # 10 ** 5
    # index < j <= index + Kの範囲にmin_xがいるか
    next_min_list = [y for y in min_x_i_list if (index < y) and y <= (index + K)]
    if next_min_list:
        index += K
        c += 1
    else:
        index += K - 1
        c += 1

print(c)

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    a = list(map(int, input().split()))

    tmp = N - K
    tmp = tmp / (K-1)
    if tmp - int(tmp) != 0:
        ans = 2 + int(tmp)
    else:
        ans = 1 + int(tmp)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))

if n == k:
    print (1)
elif k == 2:
    print(n-1)
else:
    print(-(-(n-1)//(k-1)))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))

if n == k:
  print(1)
elif k == 2:
  print(n - 1)
else:
  print(-(-(n - 1)//(k - 1)))

Submission status: Accepted

Solution code:
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n, k = na()
aaa = na()
ans = 1
n -= k
if n == 0:
    pass
elif n % (k - 1) == 0:
    ans += n // (k - 1)
else:
    ans += n // (k - 1) + 1
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
box=[map(int,input().split())]
cost,point=1,0
n=n-k
while n>0:
    n -=k-1
    cost +=1
print(cost)

Submission status: Accepted

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))

print(((n-1)+(k-2))//(k-1))

Submission status: Accepted

Solution code:
from math import ceil

N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = ceil((N-K)/(K-1) + 1)

print(ans)

Submission status: Accepted

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N, K =  map(int, sys.stdin.readline().split())
L =  list(map(int, sys.stdin.readline().split()))

if (N - K) % (K - 1) == 0:
    print((N - K) // (K - 1) + 1)
else:
    print((N - K) // (K - 1) + 2)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
print( (n - 2) // (k - 1) + 1 )

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
print(((n - 1) + (k - 2)) // (k - 1))

Submission status: Accepted

Solution code:
from sys import stdin
n, k, *a = map(int, stdin.read().split())
print(((n - 1) + (k - 2)) // (k - 1))

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,K = II()
A = III()

print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:

n, k = map(int, input().split())
a_list = list(map(int, input().split()))

one_index = None
for i in range(len(a_list)):
    if a_list[i] == 1:
        one_index = i
left_n = one_index
right_n = n - one_index - 1

delete_num = k - 1
minimum = None
for i in range(k):
    hidarihashi_index = one_index - i
    migihashi_index = one_index - i + k - 1
    if hidarihashi_index < 0:
        hidari_nokori = 0
    else:
        hidari_nokori = hidarihashi_index

    if migihashi_index > (n-1):
        migi_nokori = 0
    else:
        migi_nokori = (n-1) - migihashi_index

    if hidari_nokori % delete_num == 0:
        hidarikasan = hidari_nokori // delete_num
    else:
        hidarikasan = hidari_nokori // delete_num + 1

    if migi_nokori % delete_num == 0:
        migikasan = migi_nokori // delete_num
    else:
        migikasan = migi_nokori //delete_num + 1

    shikoukaisuu = 1 + migikasan + hidarikasan

    if not minimum:
        minimum = shikoukaisuu
    else:
        minimum = min(shikoukaisuu, minimum)
print(minimum)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == k:
    print(1)
elif n-k<=k:
    print(2)
else:
    if (n-k)%(k-1) == 0:
        print((n-k)//(k-1)+1)
    else:
        print((n-k)//(k-1)+2)

Submission status: Accepted

Solution code:
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))

print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
print(eval("-(-~-"+input().replace(" ","//~-")+")"))

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(-((1-n)//(k-1)))

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

print(math.ceil((n - 1) / (k - 1)))

Submission status: Accepted

Solution code:
# coding: utf-8
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = (N - K) // (K - 1)
if (N - K) % (K - 1) == 0:
    ans += 1
else:
    ans += 2
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

ans = (N-K)//(K-1) 

if (N-K)%(K-1) == 0:
    ans += 1
else:
    ans += 2

print(ans)

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
print((N-K)//(K-1) + 1 if (N-K)%(K-1) == 0 else (N-K)//(K-1) + 2)

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
n = list(map(int, input().split()))
print((N-K)//(K-1) + 1 if (N-K)%(K-1) ==0 else (N-K)//(K-1) + 2)

Submission status: Accepted

Solution code:
N,K = [int(i) for i in input().split()]
n = list(map(int, input().split()))
print((len(n)-K)//(K-1) + 1 if (len(n)-K)%(K-1) ==0 else (len(n)-K)//(K-1) + 2)

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
print(math.ceil((n - 1) / (k - 1)))

Submission status: Accepted

Solution code:
n,k=map(int, input().split())
a=sorted(list(map(int, input().split())))

if n%k!=0:
    for _ in range(n%k):
        a.append(10**6)

ans=0
for i in range(0,n-1,k-1):
    ans+=1

print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
from functools import reduce
import copy
import math


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, K] = string_to_int(inputs[0])
    paint_range = K-1
    A = string_to_int(inputs[1])
    one_index = None

    for i, a in enumerate(A):
        one_index = i if a == 1 else one_index
    count = one_index // paint_range
    r = one_index % paint_range
    over = 0
    if r != 0:
        count += 1
        over = paint_range - r
    count += math.ceil(((N-1) - one_index - over) / paint_range)
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)

Submission status: Accepted

Solution code:
import math

def main():
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]

    j = 0
    for i in range(N):
        if A[i] == 1:
            j = i
            break
    min_v = float('inf')
    for i in range(j, j-K, -1):
        v = 1 + math.ceil(max(i, 0)/(K-1)) + math.ceil(max(0, N-K-i)/(K-1))
        min_v = min(min_v, v)
    return min_v

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int, A: "List[int]"):

    ans = math.ceil((N-1)/(K-1))
    print(ans)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int, A: "List[int]"):
    ix = A.index(1)

    ans = math.ceil((N-1)/(K-1))
    print(ans)


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(N: int, K: int, A: "List[int]"):
    ix = A.index(1)

    # if(K == N):
    #     print(1)
    #     exit()

    # ans = min(math.ceil(len(A[:max(0,ix-1)])/(K-1))+math.ceil(len(A[min(ix+2,len(A)):])/(K-1))+1,
    #         math.ceil(len(A[:ix])/(K-1))+math.ceil(len(A[ix+1:])/(K-1)))
    # print(ans)

    ans = math.ceil((N-1)/(K-1))
    print(ans)


    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

n,k = map(int,input().split())

print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
N, K = [int(s) for s in input().split()]
print(1 -(-(N-K)//(K-1)))

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
nums = list(map(int, input().split()))
print(math.ceil((len(nums)-1)/(K-1)))

Submission status: Accepted

Solution code:
import math
def solve():
  n,k = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  ct = 1
  n -= k
  if n>0:
    ct += math.ceil(n/(k-1))
  print(ct)
solve()

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))

if N == K:
    print(1)
else:
    tmp = N - K
    ans = 1 + tmp // (K-1)

    if tmp % (K-1) != 0:
        ans += 1        
    
    print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
l = list(map(int, input().split()))

ans = 0
i = 0
while i < n-1:
  i += k-1
  ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
one=a.index(1)
left=one
right=n-(one+1)

from math import ceil
print(ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
one_index = a.index(1)
ans = 10 ** 6
for i in range(one_index - (k-1) ,one_index + (k-1) + 1 ):
    l = i
    r = i + (k-1)
    cnt_l = 0
    cnt_r = 0
    if l >= 0:
        if l % (k-1) == 0:
            cnt_l = l // (k-1)
        else:
            cnt_l = l // (k-1) + 1
        
    if r < n:
        if (n-1-r) % (k-1) == 0:
            cnt_r = (n-1-r) // (k-1)
        else:
            cnt_r = (n-1-r) // (k-1) + 1
    ans = min(ans, 1 + cnt_l + cnt_r)
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=input()
import math
print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=input()
x=(n-1)/(k-1)
if x==int(x):
    print(int(x))
else:
    print(int(x)+1)

Submission status: Accepted

Solution code:
import math
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
import math

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    print(math.ceil((N - 1) / (K - 1)))

main()

Submission status: Accepted

Solution code:
N, K = [int(_) for _ in input().split()]

A = [int(_) for _ in input().split()]

m = min(A)
# idx = A.index(m)
i = 0
ans = 0
while i < N:
    if i ==0:
        i+=K
    else:
        i += K - 1
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
if (n-1)%(k-1)==0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1)+1)

Submission status: Accepted

Solution code:
def main():
  n, k = map(int,input().split())

  print((n - 2) // (k - 1) + 1)

main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))

ans = -(-(n-1)//(k-1))

print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

div, mod = divmod(N - 1, K - 1)
if mod == 0:
    print(div)
else:
    print(div + 1)

Submission status: Accepted

Solution code:
import os,re,sys,operator,math
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)

n,k=map(int,stdin.readline().rstrip().split())
a=[int(i) for i in stdin.readline().rstrip().split()]
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
min_num = 1
min_index = A.index(min_num)

left_opes = math.ceil(min_index / (K - 1))
left_index = left_opes * (K - 1)

right_opes = math.ceil((N - 1 - left_index) / (K - 1))

print(left_opes + right_opes)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = [int(i) for i in input().split()]

idx = 0

for i in range(n):
    if a[i] == 1:
        idx = i
        break

if n <= k:
    print(1)
    exit()

print((n-1+k-2)//(k-1))
exit()
ans = (n-idx+k-2)//(k-1) + (idx+k-2)//(k-1)

for i in range(k-1):
    ans = min(ans,  (n-idx+k-2-1-i)//(k-1) + (idx+k-2-(k-2-i))//(k-1) + 1)
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
d = k - 1
print((n + d - 2) // d)

Submission status: Accepted

Solution code:
import math

N,K = map(int, input().split())

lst = list(map(int, input().split()))

print(math.ceil((N - K) / (K - 1)) + 1)

Submission status: Accepted

Solution code:
from math import ceil
N,K = map(int,input().split())
alist = list(map(int,input().split()))

print(ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
import itertools
import collections

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,k = getints()
a = getints()


print((n-1+k-1-1)//(k-1))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

def ceil(x, y) :
    return (x + y - 1) // y

ans = ceil(N - K, K - 1) + 1
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
if (N-1)%(K-1)>0:
    print((N - 1) // (K - 1) + 1)
else:
    print((N-1)//(K-1))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=1
n-=k
while n>0:
    n-=k-1
    ans+=1
print(ans)

Submission status: Accepted

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
print(math.ceil((n-k)/(k-1)+1))

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  if a[i] == 1:
    one = i
print( (i-1)//(k-1) + (n-i-2)//(k-1) + 2 )

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
l = list(map(int, input().split()))
print(math.ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
N, K = map(int,input().split())

ans = -(-(N-1)//(K-1))
    
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, A: "List[int]"):
    print(math.ceil(1+(N-K)/(K-1)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

n,k = map(int,input().split())
lst = [int(i) for i in input().split()]

for i in range(n):
    if lst[i] == 1:
        start = i

l = start #1より左側の数字数
r = n - start -1 #１より右側の数字数

if k==1:
    print(n)
elif n==k:
    print(1)

else:
    if l == 0: #numl : 左側領域の試行回数
        numl = 0
    elif l <= k-1:
        numl = 1
    elif l % (k-1) == 0:
        numl = l // (k-1)
    else:
        numl = (l // (k-1)) + 1
    
    if r == 0: #numr : 右側領域の試行回数
        numr = 0
    elif r <= k-1:
        numr = 1
    elif r % (k-1) == 0:
        numr = r // (k-1)
    else:
        numr = (r // (k-1)) + 1
    pat1 = numr + numl
    
    if (n-k)%(k-1)==0:
        pat2 = 1 + (n-k)//(k-1)
    else:
        pat2 = 2 + (n-k)//(k-1)
    print(min(pat1,pat2))

Submission status: Accepted

Solution code:
import math
N, K = map(int, input().split())
l = list(map(int, input().split()))
print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = -(-(N-1) // (K-1))

print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))

res = 0
if (N-1)%(K-1) == 0:
    res = (N-1)//(K-1)
else:
    res = (N-1)//(K-1)+1
print(res)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = 1
N -= K
while N > 0:
    N -= K - 1
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
from math import*
n,k=map(int,input().split())
print(ceil(~-n/~-k))

Submission status: Accepted

Solution code:
from math import*
n,k=map(int,input().split())
print(ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())

A = [int(i) for i in input().split()]

ans = -(-(N - 1) // (K - 1))

print(ans)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())

A = list(map(int,input().split()))

ans = -((-(N-1))//(K-1))
print(ans)

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))

a = a[k:]
c = 1

c += math.ceil(len(a) / (k-1))
print(c)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
li = list(map(int, input().split()))
if (n-1)%(k-1) == 0:
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1) +1)