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:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n,k = MI()
a = RI()

ind = a.index(1)
ans = INF

if ind>(k-1) and ind<(n-k):
    for i in range(ind-k+1,ind+k):
        # print('i={}'.format(i))
        m = 0
        m += ceil(i/(k-1))
        m += ceil((n-i-1)/(k-1))
        ans = min(ans,m)
        # print('ans={}'.format(ans))
elif ind<=(k-1):
    ans = 0
    ans += ceil((n-k)/(k-1)) + 1
else:
    ans = 0
    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 + k - 1) // k == 1:
    print(1)
else:
    res = ((n - k) + (k - 2)) // (k - 1) + 1
    print(res)

Submission status: Accepted

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

now = k
res = 1
while now < n:
    now += k-1
    res += 1

print(res)

Submission status: Accepted

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

i = a.index(1)

s = n

for j in range(i-k+1, i+k):
    if j < 0:
        continue
    elif j >= n:
        continue
    else:
        l = j
        u = (n-1-j)
        t = (l+k-2) // (k-1) + (u+k-2) // (k-1)
        #print(t)
        s = min(s, t)

print(s)

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:
n, k = map(int, input().split())
a = list(map(int, input().split()))

m = n-k
if m>0:
  if m%(k-1)==0:
    print(m//(k-1) + 1)
  else:
    print(m//(k-1) + 2)
else:
  print(m//(k-1) + 1)

Submission status: Accepted

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

ans = 1
ref = K
while ref < N:
    ans += 1
    ref += K-1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def waru(a,b):
  if a%b==0:
    return a//b
  else:
    return (a//b)+1
N,K=map(int,input().split())
L=list(map(int,input().split()))
mina=min(L)
ind=list()
R=[0]*N
for i in range(N):
  if L[i]==mina:
    ind.append(i)
    R[i]+=1
for i in range(1,N):
  R[i]=R[i-1]+R[i]
s=ind[0]
a=waru(s,K-1)
b=(a*(K-1))-s
susumi=b+s+1
#.......a. b+sだけ進んでる
while True:
  if susumi>=N:
    print(a)
    break
  if R[min(susumi+K,N-1)]-R[susumi]>0:
    susumi+=K
    a+=1
  else:
    susumi+=K-1
    a+=1

Submission status: Accepted

Solution code:
from math import ceil

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

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


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

Submission status: Accepted

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

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

Submission status: Accepted

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

pos_of_1 = A.index(1)

if K >= pos_of_1 + 1 or N - K <= pos_of_1:
  print(math.ceil((N - K) / (K - 1)) + 1) 
else:
  L = A[:pos_of_1 + 1]
  R = A[pos_of_1:]
  res = []
  for i in range(1, K):
    l = math.ceil((len(L) - i) / (K - 1)) + 1
    r = math.ceil((len(R) - K - 1 + i) / (K - 1)) + 1
    res.append(l + r - 1)
  print(min(res))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(100000):
  if N<=K+i*(K-1) :
    print(i+1)
    exit()

Submission status: Accepted

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n, k = nm()
    A = nl()
    print((n - 1) // (k - 1) if (n - 1) %
          (k - 1) == 0 else (n - 1) // (k - 1) + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math


def main():
    n, k = map(int, input().split())
    As = list(map(int, input().split()))
    ans = math.ceil((n-1)/(k-1))
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    n, k = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 1
    n -= k
    ans += (n+k-2) // (k-1)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

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

p = 0
for i in range(n):
    if aa[i] == 1:
        p = i
        break

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *A = map(int, read().split())

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

    return


if __name__ == '__main__':
    main()

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:
#!/usr/bin/env python3
import math

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

index = a.index(1)

pre = index
post = n-index-1

ans = 10**10
for i in range(0, k):
    ans_tmp = 0
    pre_tmp = max(0, pre-i)
    post_tmp = max(0, post-(k-1-i))
    ans_tmp += math.ceil(pre_tmp/(k-1))
    ans_tmp += math.ceil(post_tmp/(k-1))
    ans = min(ans, ans_tmp)
    # print(pre_tmp, post_tmp, ans)

print(ans+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()))
import math
ans = math.ceil((n - 1) / (k - 1))
print(ans)

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
List = list(map(int, input().split()))
k=K-1
n = (N-1)/k
nn = int(n)
if n-nn > 0:
  nn = nn+1
print(nn)

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

Submission status: Accepted

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

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,1][n==k])

Submission status: Accepted

Solution code:
import math

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

if K == N:
  print(1)
else:
  print(math.ceil((N - K) / (K - 1)) + 1)

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
ix=a.index(1)
i=math.ceil((n-k)/(k-1))+1
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=(int(i) for i in input().strip().split(" "))
ar=[int(i) for i in input().strip().split(" ")]
from math import ceil
pos=ar.index(1)
a=n-1-pos
b=pos
a1=(a//(k-1))
a2=b//(k-1)
c=ceil((n-1-((a1+a2)*(k-1)))/(k-1))
print(a1+a2+c)

Submission status: Accepted

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

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

if n==k:
    print(1)
    exit()
    
x = 1+(n-k)//(k-1)
y = (n-k)%(k-1)

if y >0:
    print(x+1)
else:
    print(x)

Submission status: Accepted

Solution code:
#全部1にしたい
n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
#端っこから区間をあらかじめ区切っておく
ans=0
i=0
while i<n-1:
  ans=ans+1
  i=i+k-1
  
  
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
t = A.index(1)
ans = 10 ** 7
for i in range(K):
    pre = max(t + i, 0)
    tail = max(N - 1 - t - i, 0)
    unit = K - 1
    pre_unit = -(-pre // unit)
    tail_unit = -(-tail // unit)
    ans = min(ans, pre_unit + tail_unit)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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
a,b = map(int,input().split())
c = input()
print(ceil((a-1)/(b-1)))

Submission status: Accepted

Solution code:
a,b = map(int,input().split())
c = input()
print((a+b-3)//(b-1))

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,K = MI()
A = LI()

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

Submission status: Accepted

Solution code:
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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()))
print((n-1)//(k-1)+((n-1)%(k-1)>0))

Submission status: Accepted

Solution code:
import sys
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()]

b = a.index(1) 
ans = 0
b -= (k-1)
if b < 0:
    b = a.index(1) + abs(b)
if b > n-1 -(k-1):
    b -= b- (k-1)
c,d = divmod(b,k-1)
ans += c
if d != 0:
    ans +=1
e,f = divmod(n-1 - b,k-1)
ans += e
if f != 0:
    ans +=1
if d != 0 and f != 0 and d + f <= 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()))


if (N-K)%(K-1)==0:
    ans = 1+(N-K)//(K-1)
else:
    ans = 2+(N-K)//(K-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-1)/(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 = 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()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int , raw_input().split())
c = n - k 
p = k - 1
print 1 + (c + p-1)/p

Submission status: Accepted

Solution code:
NK = list(map(int,input().split()))
A = list(map(int,input().split()))
N = NK[0]
K = NK[1]

answer = (N - 1) // (K - 1)
remain = (N - 1) % (K - 1)
if remain > 0:
    answer = answer + 1
print(answer)

Submission status: Accepted

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

l=n-k
r=k-1
if l%r==0:
  print(l//r+1)
else:
  print(l//r+2)

Submission status: Accepted

Solution code:
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
Left  = A.index(1)
Right = (N-1)-Left
Count = (Right%(K-1)!=0)+Right//(K-1)
Left -= ((K-1)-Right%(K-1))%(K-1)
Count += (Left%(K-1)!=0)+Left//(K-1)
print(Count)

Submission status: Accepted

Solution code:
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
Left  = A.index(1)
Right = (N-1)-Left
Count = (Right%(K-1)!=0)+Right//(K-1)
Left  -= (Right%(K-1)!=0)*((K-1)-Right%(K-1))
Count += (Left%(K-1)!=0)+Left//(K-1)
print(Count)

Submission status: Accepted

Solution code:
import math
N, K = map(int, input().split())
A = input()
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()))

# 並び順を変えても普遍
ans = 0
i = 0

while True:
    if i*(K-1) >= N-1:
        break
    ans += 1
    i += 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:
N,K=map(int,input().split())
A=list(map(int,input().split()))
if N<=K:
  print(1)
else:
  i=K
  a=1
  while i<N:
    i+=(K-1)
    a+=1
  print(a)

Submission status: Accepted

Solution code:
n, k = [ int(i) for i in input().split(' ') ]
xs = [ int(x) for x in input().split(' ') ]
i0 = xs.index(min(xs))
print(1 + min([ (i + k - 2) // (k - 1) + (n - i - 2) // (k - 1)
  for i in range(max(i0 - k + 1, 0), min(i0, 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:
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 math
def main():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    print(math.ceil((n-k)/(k-1)+1))
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = a.index(1)
ans = 9999999999
left = len(a[:m])
right = len(a[m:])
for i in range(k):
    x = left  - i
    y = right - (k-i)
    if x < 0 or y < 0:
        continue
    count = 1 + math.ceil(x/(k - 1)) + math.ceil(y/(k - 1))
    ans = min(ans,count)
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:
n,k = map(int, input().split())
a = list(map(int, input().split()))
if (n==k):
    print(1)
else:
    print(1+(n-k-1)//(k-1)+1)

Submission status: Accepted

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

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

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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]"
    print(solve(N, K, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    if n <= k:
        print(1)
        sys.exit()
    else:
        r = ceil((n - 1) / (k - 1))
        print(r)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = (N-1)//(K-1)
if (N-1)%(K-1)!=0:
    ans+=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] = list(map(int,input().split()))
A = list(map(int,input().split()))

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

print(out)

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:
import sys,math
input = sys.stdin.readline

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

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

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
for i in range(10**5+1):
    N-=K
    cnt+=1
    if N<=0:
        break
    else:
        N+=1
print(cnt)

Submission status: Accepted

Solution code:
import math
N, K = list(map(int,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()))

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

Submission status: Accepted

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

print(n)

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(int(a) for a in 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()))
ans = k
count = 1
while ans < n:
    ans += k-1
    count += 1
print(count)

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

Submission status: Accepted

Solution code:
N, K = list(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()))
from math import ceil
print(ceil((N-1)/(K-1)))

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    readline()

    if K == 2:
        print(N - 1)
        exit()

    q, r = divmod(N, K - 1)
    if r in (0, 1):
        ans = q
    else:
        ans = q + 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
lst = list(map(int, input().split()))
idx = lst.index(1)
k -= 1
a = (len(lst[:idx]) + k - 1) // k
b = (len(lst[idx + 1:]) + k - 1) // k
c = ((n - 1) + k - 1) // k
print(min(c, a + b))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

ans = 0

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

Submission status: Accepted

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

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


if __name__ == "__main__":
    main()

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 sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N,K = I()
A = l()
i = A.index(1)
ans = 10**9
for j in range(K):
    ans = min(ans,math.ceil(max(i-j,0)/(K-1))+math.ceil(min((N-i-1+j),N-1)/(K-1)))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, k = MI()
    a = LI()
    ans = -(-(n-1) // (k-1))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

n, k = map(int, input().split())
lis = 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()))
b=min(A)
p=0
for i in range(N):
  if A[i]!=b:
    p+=1
if p%(K-1)==0:
  print(p//(K-1))
else:
  print(p//(K-1)+1)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n<=k:
    print(1)
    exit()
c=1
while 1:
    if n<=k:
        break
    n-=(k-1)
    c+=1
print(c)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def func(n, k):
    """
    n個のものをk個ずつ重なり1でとる回数
    """
    if n <= 1: return 0
    if n <= k: return 1
    if (n - k) % (k - 1) == 0: return 1 + (n - k) // (k - 1)
    return 1 + (n - k) // (k - 1) + 1

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    place = 0
    for i in range(N):
        if A[i] == 1:
            place = i
            break
    """
    1を常に端点にとると失敗する！
    反例：A=[2,3,4,1,5,6,7], K=3
    """
    ans = 10**10
    for i in range(K):
        ans1 = func(place - i + 1, K)
        ans2 = func((N - place) - (K - i) + 1, K)
        #print("i={}, ans1={}, ans2={}".format(i, ans1, ans2))
        ans = min(ans, ans1 + ans2 + 1)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

count = 0

while n > 0:
    if n > k:
        n -= k-1
    else:
        n -= k
    count += 1

print(count)

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:
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    for x in range(1, N+1):
        if (K-1)*x + 1 >= N:
            ans = x
            break
    print(ans)
main()

Submission status: Accepted

Solution code:
import math
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k, *a = map(int, readline().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt = 1

ans = K

while ans < N:
    cnt += 1
    ans += K-1

print(cnt)

Submission status: Accepted

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

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)))
# 1以外のn-1個のうち、1回で最大k-1個まで1にできる

Submission status: Accepted

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

def main():
	N,K=map(int,input().split())
	A=list(map(int,input().split()))
	if (N-1)%(K-1):
		print((N-1)//(K-1)+1)
	else:
		print((N-1)//(K-1))
if __name__=='__main__':
	main()

Submission status: Accepted

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

ans = 1
N -= K

while N > 0:
    N -= 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:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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

    ans = 1
    N -= K
    ans += (N + K - 2)//(K - 1)
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import bisect
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N==K: print(1);exit()
N-=K
ans = 1
while N>0:
    N -=K-1
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
Ax = list(map(int, input().split()))
if N == K:
    print(1)
    exit()

N -= K
ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
num=min(a)
if a[0]==num:
    n-=1
if a[-1]==num:
    n-=1
n-=1
k-=1
print(-1*(n//-k))

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
eq = 1
cnt = int()
while eq<N:
    eq += (K-1)
    #print(cnt, eq)
    cnt +=1

print(cnt)

Submission status: Accepted

Solution code:
import sys
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
start = 0
end = k
count = 0
for i in range(n):
    if a[n-1]==1:
        print(count)
        sys.exit()
    a[start:end] = [1]*k
    start += (k-1)
    end += (k-1)
    count += 1

Submission status: Accepted

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