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())
if n==k:
  print(1)
elif k==2:
  print(n-1)
elif n%(k-1)==1:
  print(n//(k-1))
else:
  print((n+k-2)//(k-1))

Submission status: Accepted

Solution code:
N,K = (map(int , input().split()))
A = list(map(int , input().split()))
con = 0
ans = 0
iti = 1
ans = K-1 + iti
while N > ans:
    ans += K-1
    con += 1
print(con+1)

Submission status: Accepted

Solution code:
import math
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if N == K:
    print(1)
else:
    print(math.ceil((N-1)/(K-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a,b = map(int,input().split())
l = sorted(list(map(int,input().split())))

ans = math.ceil((a-1) / (b-1))
print(ans)

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:
n, k = map(int, input().split())
A = list(map(int, input().split()))
answer = 100000
while True:
    if n <= k + (k - 1) * (answer - 1):
        answer -= 1
    else:
        break

print(answer + 1)

Submission status: Accepted

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

if (n-k)%(k-1)==0: print(1+(n-k)//(k-1))
else: print(1+(n-k)//(k-1)+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:
import math
import itertools
#n = int(input())
#n, d = list(input().split())
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
point = 0
i = 0
while N > point:
    i+=1
    if i==1:
        point+=K
    else:
        point+=(K-1)

print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics


# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===


data1 = getInputListInt()
n = data1[0]
k = data1[1]
data2 = getInputListInt()

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

print(ans)

Submission status: Accepted

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


def ceil(x, y):
    if x % y == 0:
        return x // y
    else:
        return x // y + 1


print(ceil(n-1, k-1))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
a = input()
ans = []
left = a.index('1')
right = n -left -1
for i in range(k):
    l = left-i
    r = right-k+1+i
    if l==0:
        ans.append(right//k+1)
    else:
        ans.append((l-1)//(k-1)+1+1+(r-1)//(k-1)+1)
print(min(ans))

Submission status: Accepted

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

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

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
if n <= k:
    print(1)
else:
    print(math.ceil((n - k) / (k - 1)) + 1)

Submission status: Accepted

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

Submission status: Accepted

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

ii=0
for i in range(N):
    if A[i]==1:
        ii=1

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

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:
nk=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nk[0]
k=nk[1]
def min(A):
  min=1000000
  for x in range(len(A)):
    if A[x]<=min:
      min=A[x]
  return min
m=0
for i in range(n):
  if a[i]==1:
    m=i
l=[]
if n<=k:
  l.append(1)
else:
  for j in range(k):
    if j<k-1:
      l.append(100000)
    elif j>=k-1 and j%(k-1)==0 and (n-j-1)%(k-1)==0:
      l.append(j//(k-1)+(n-j-1)//(k-1))
    elif j>=k-1 and j%(k-1)!=0 and (n-j-1)%(k-1)!=0:
      l.append(j//(k-1)+1+(n-j-1)//(k-1)+1)
    elif j>=k-1 and j%(k-1)!=0 and (n-j-1)%(k-1)==0:
      l.append(j//(k-1)+1+(n-j-1)//(k-1))
    elif j>=k-1 and j%(k-1)==0 and (n-j-1)%(k-1)!=0:
      l.append(j//(k-1)+(n-j-1)//(k-1)+1)
print(min(l))

Submission status: Accepted

Solution code:
from math import ceil


def main():
    length, section_range = map(int, input().split(" "))
    numbers = list(map(int, input().split(" ")))
    print(ceil((length - 1) / (section_range - 1)))


if __name__ == '__main__':
    main()

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()))

ans=1
X=N-K

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

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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:
N, K = [int(i) for i in input().split()]

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

n = N - K 

q, r = divmod(n, (K-1))
if r == 0:
    print(q + 1)
else :
    print(q + 2)

Submission status: Accepted

Solution code:
import sys
import math

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

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

Submission status: Accepted

Solution code:
import math

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

ans = math.ceil((N - 1) / (K - 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:
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

def main():
    N, K = map(int, input().split())
    input()
    print(math.ceil((N-K)/(K-1) + 1.0))

main()

Submission status: Accepted

Solution code:
import math

N, K = map(float, input().split())
_ = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a,b = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
 
ans = 1 + int(math.ceil((a-b)/(b-1)))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

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

idx = a.index(1)
num_l = idx
num_r = n - idx - 1

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
count =0
while True:
    count += 1
    n -= (k)
    if n <= 0:
        break
    n += 1
print(count)

Submission status: Accepted

Solution code:
import math
n,k=map(int,input().split())
a=[int(x) for x in input().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()))
print(int(math.ceil((len(A)-k)/(k-1)))+1)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
#最終的にすべての値は1になる
if N==K:
    print(1)
    exit()
ans = 1
t = K
while(1):
    if t >= N:
        print(ans)
        exit()
    t += (K-1)
    ans += 1

Submission status: Accepted

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

Submission status: Accepted

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

idx = a.index(1)
ans = 0

ans += -(-idx // (k-1))
ans += -(-(n - ans * (k-1) - 1) // (k-1))

print(ans)

Submission status: Accepted

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

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:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
print(math.ceil((n-1)/(m-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
[int(i) for i in input().split()]
print(math.ceil((n-k) / (k - 1) + 1))

Submission status: Accepted

Solution code:
import math
n,k=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()))

if (n-1)%(k-1) != 0:
  cnt = (n-1)//(k-1)+1
else:
  cnt = (n-1)//(k-1)
  
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

count = 1
s = K
for _ in range(N):
  if s >= N:
    break
  s += K-1
  count += 1

print(count)

Submission status: Accepted

Solution code:
import math

def solve(n, k, A):
    return math.ceil((len(A) - A.count(min(A))) / (k - 1))

_n, _k = map(int, input().split())
_A = list(map(int, input().split()))
print(solve(_n, _k, _A))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def ceil(a, b):
    return -(-a // b)


print(ceil(n-1, k-1))

Submission status: Accepted

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

a = math.ceil(A.index(1)/(K-1))
b = math.ceil((N-a*(K-1))/(K-1))
ans = min(a+b, math.ceil((N-1)/(K-1)))
print (ans)

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()))
idx = a.index(1)
if idx == 0:
    print(-(-len(a[(idx + 1):]) // (k - 1)))
elif idx == (n - 1):
    print(-(-len(a[:idx]) // (k - 1)))
else:
    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(min(A))
r=a
l=N-(r+1)
rc=r//(K-1)
lc=l//(K-1)

if N-(rc+lc)*(K-1)==1:
  print(rc+lc)
elif 1<N-(rc+lc)*(K-1)<=K:
  print(rc+lc+1)
else:
  print(rc+lc+2)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==k:
    print(1)
    exit()
i=n-k
ans=1
while i>0:
    i=i-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()))
g = 1 
i = 0
while g < n:
    g += (k -1)

    i += 1
print(i)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 1
n = (N-K)//(K-1)
ans += n
if N-K-n*(K-1) > 0:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
from math import ceil

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

Submission status: Accepted

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

mar = k - 1  # max replacible count

ret = 1 + (n - k + mar - 1) // mar
print(ret)

# 左端から長さKの区間をのりしろ1で貼り続ける
# 最小値1を含む要素に重なる区間から順に操作を始めれば可能
# i = a.index(1)
# mar = k - 1  # max replacible count
#
# le = (i + mar - 1) // mar  # [0,i)
# ri = (n - i - 1 + mar - 1) // mar  # [i+1,n)
#
# print(le + ri)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import math

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

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




if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
mini = a.index(1)
l = mini // (k-1)
lm = mini % (k-1)
r = (n - mini - 1) // (k-1)
rm = (n - mini - 1) % (k-1)
# print(l, r, lm, rm)
print(l + r + ((lm + rm + 1) // k + ((lm + rm + 1) % k != 0 and (lm + rm) != 0)))

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())
input()
print(1 if n==k else 1+(n-2)//(k-1))

Submission status: Accepted

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
idx_minA = A.index(min(A)) + 1

if N <= K:
    print(1)
else:
    ans = float('inf')
    for i in range(max(1, idx_minA - K + 1), idx_minA + 1):
        ans = min(ans, 1 + math.ceil((i - 1) / (K - 1)) + math.ceil((N - (i + K - 1)) / (K - 1)))
    print(ans)

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
# 1回の操作で増やせる1に等しい要素の数はK−1

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

# ceil(N-1/K-1)
print((N-1+K-2)//(K-1)) # ceil = x+y-1

Submission status: Accepted

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

Submission status: Accepted

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

a=(N-1)%(K-1)
b=(N-1)//(K-1)

if a==0:
  print(b)
else:
  print(b+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p = 0
cnt= 0

while p < n - 1:
    p += k - 1
    cnt += 1
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC101 C

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()))

for i in range(n+10):
    if k*i-(i-1)>=n:
        print(i)
        break

Submission status: Accepted

Solution code:
from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))
#mini = A.index(1)
print(ceil((N-K)/(K-1))+1)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC101 C - Minimization
# N <= K + (K-1)(g-1)を満たす最小のgが答え
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
g = 1
while True:
    if N <= K + (K-1)*(g-1):
        break
    else:
        g += 1
print(g)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

from math import ceil

def main():
    print(ceil((n-1)/(k-1)))
        
if __name__ == "__main__":
    main()

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:
import sys

n, k, *a = map(int, sys.stdin.read().split())

def main():
    return ((n - 1) + (k - 1) - 1) // (k - 1)

if __name__ == '__main__':
    ans = main()
    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-1)/(K-1)))

Submission status: Accepted

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

Submission status: Accepted

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

index = lst1.index(1)

print(math.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 = 0

while n > 0:
    n -= k
    ans += 1
    if n > 0: n += 1

print(ans)

Submission status: Accepted

Solution code:
from math import ceil

N, K = map(int, input().split())
A = [int(x) for x in input().split()]

A.sort()
t = 0
for i in range(N):
    if A[i]==A[0]:
        t += 1
    else:
        break

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
def solve(N: int, K: int, A: "List[int]"):
    # 最小値は絶対1になる
    cur = K
    answer = 1 + math.ceil((N-K)/(K-1))
    print(answer)
    return


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())
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:
import math

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

for i in range(n):
    if(A[i] == 1):
        key = i

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()))
from bisect import bisect_left as bl
x=bl(A,1)
ans=0
ans+=-(-(N-x-1)//(K-1))
ans+=-(-x//(K-1))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

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 = map(int, (input().split()))

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
 
s = K
i = 1
while True:
    if s >= N:
        print(i)
        break
    i+=1
    s+=K - 1

Submission status: Accepted

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

n = N - 1
k = K - 1

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

print(ans)

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:
from math import ceil

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

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

Submission status: Accepted

Solution code:
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:
# -*- coding: utf-8 -*-

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 = [int(i) for i in input().split()]
print(-(-(n-1)//(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 -*-
import sys
input = sys.stdin.readline

n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
#1のindexを取得
# one_idx = a.index(1)
#
# from decimal import Decimal
#
# left_list_len = one_idx
# right_list_len = n - one_idx - 1
#
#
# print(left_list_len//(k-1)+ right_list_len//(k-1) + min(left_list_len%(k-1),1) + min(right_list_len%(k-1),1))

#左からk-1個を1に変える操作を繰り返す(k=2の時だけ別)
if k==2:
    ret = n-1
else:
    ret = (n-1)//(k-1)+min((n-1)%(k-1),1)
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
A = np.array([int(x) for x in input().split()],np.int64)
ans = 0
cnt = 0
minA = np.argmin(A)
leftA = A[:minA]
rightA = A[minA+1:]
x = len(leftA)
y = len(rightA)
for i in [x,y]:
    ans += i // (K-1)
    cnt += i % (K-1)
if cnt % (K-1) == 0:
    ans += cnt // (K-1)
else:
    ans += 1 + cnt // (K-1)
print(ans)

Submission status: Accepted

Solution code:
import math
i = input()
i = i.split()
N = int(i[0])
K = int(i[1])

i = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N , K = (int(i) for i in input().split())
A = list(int(i) for i in input().split())
 
count = 1
s  = K
 
while s < N:
    s = s + (K - 1)
    count = count + 1
    #print(s)
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#1にしなきゃいけない
from math import*

n,k=map(int,input().split())
a=list(map(int,input().split()))
#b=a.index(1)
#print(n,k,b)

#l=b
#r=n-b-1
print((n-1+k-1-1)//(k-1))

Submission status: Accepted

Solution code:
#1にしなきゃいけない
from math import*

n,k=map(int,input().split())
a=list(map(int,input().split()))
#b=a.index(1)
#print(n,k,b)

#l=b
#r=n-b-1
print(ceil((n-1)/(k-1)))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
li=[]
import collections
import math
A=collections.Counter(a)
for key in A.keys():
    li.append(key)
x=A[li[0]]
print(math.ceil((n-x)/(k-1)))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    if i==1:
        p=i
        break
ans=0
ans+=(p+k-1)//(k-1)
p=n-1-p-(k-1-p%(k-1))
ans+=(p+k-2)//(k-1)
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
TMP=K
ANS=1
if N <= K:
  ANS=1
else:
  while True:
    TMP+=(K-1)
    ANS+=1
    if N <= TMP:
      break
print(ANS)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
sum_k = k
ans = 1
while sum_k < n:
    sum_k = sum_k + k - 1
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
def count(num):
    if num%(k-1)==0:
        a=(num//(k-1))
    else:
        a=(num//(k-1)+1)
    return a
if n==k:
    print(1)
else:
    one=0
    ans=0
    for i in range(n):
        if a[i]==1:
            one=i+1 #１が左からone番目にある(１スタート)
            break
    l=one-1 #１より左にある数
    r=n-one
    c=0
    if l==0:
        ans+=count(r)
        c=1
    if r==0:
        ans+=count(l)
        c=1
    if c==0:
        cl,cr=count(l),count(r)
        l_start=cl+count(r-(cl*(k-1)-l))
        r_start=cr+count(l-(cr*(k-1)-r))
        ans=min(l_start,r_start)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
min_a = min(a)
count = 0
for i in range(n):
    if min_a != a[i]:
        count += 1
a, b = divmod(count, k-1)
if b == 0:
    print(a)
else:
    print(a+1)

Submission status: Accepted

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

#どうせ最小値になる、最初は最小値
#前から個数数えてく
n-=k
print(math.ceil(n/(k-1))+1)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
print((N - 1) // (K - 1) + int((N - 1) % (K - 1) != 0))

Submission status: Accepted

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

m = 10**8
idx = 0
for i in range(N):
    if A[i] < m:
        m = A[i]
        idx = i

cnt = 0
i = 0
while i < N - 1:
    i += K - 1
    cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
ichi=a.index(1) #1の位置(index番号)

ans=float("inf")
#1を含むKの位置をずらしていって最小になるとこを探す…
#端に行き渡らせるまでに、左右それぞれ何回かかるかの式求める。
import math
for i in range(k):
  if ichi-i<0 or ichi+k-i>n: #この条件は合ってるっぽい
    #print(i,"アウト")
    continue
  left=math.ceil((ichi-i)/(k-1)) #左端までかかる回数 これは正しいはず、
  right=math.ceil((n-ichi-(k-i))/(k-1)) #右端までかかる回数
  #print(ichi-i,left,right)
  ans=min(ans,1+left+right)
print(ans)