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

Submission status: Accepted

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

def solve(N: int, K: int, A: "List[int]"):
    index_1 = np.argsort(A)[0]
    if K >= N:
        return print(1)
    l = index_1
    r = N - index_1 - 1
    ans = math.ceil((l + r) / (K - 1))
    print(ans)

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:

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


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


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    N, K = MI()
    A = LI()
    print((N+K-3)//(K-1))
    # a = min(A)
    # count = []

    # tmp = 0
    # for i in range(len(A)):
    #     if A[i] != a:
    #         tmp += 1
    #     else:
    #         count.append(tmp)
    #         tmp = 0

    # if tmp != 0:
    #     count.append(tmp)

    # print(count)

    # ans = 0
    # for c in count:
    #     # print(c, (K-1), math.ceil(float(c) / (K-1)))
    #     ans += math.ceil(float(c) / (K-1))
    # print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

n,k = map(int,readline().split())
answer = (n-1+k-2)//(k-1)
print(answer)

Submission status: Accepted

Solution code:
N,K = 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=list(map(int,input().split()))
print(-(-(n-1)//(k-1)))

Submission status: Accepted

Solution code:
def examC():
    N, K = LI()
    A = LI()
    for i,a in enumerate(A):
        if a==1:
            locate1 = i
            break
    ans = (N+K-3)//(K-1)
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
print((N+K-3)//(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)))
print(ans)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
position = A.index(1)
left = position
right = n - position - 1
#print(left, right)
counter = 0
import math
counter += math.ceil(left / (k - 1))
if left % (k-1) != 0:
  right -= (k-1) - (left % (k-1))
counter += math.ceil(right / (k - 1))
print(counter)

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
list_a = list(map(int, input().split()))
count = 1
if n != k:
  n = n - k
  while n > 0:
    n -= k-1
    count += 1
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

q, mod = divmod(int(n) - 1, int(k) - 1)

if mod == 0:
  print(q)
else:
  print(q + 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:
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 =(int(i) for i in input().split())

count = 1
pos = k
for i in range(k,100000) :
  if n <= pos :
    break  
  pos += k-1
  count+=1  

print(count)

Submission status: Accepted

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

if N == K:
    print(1)
else:
    N = N - K
    count = 1
    while N>0:
        N -= K - 1
        count += 1
    print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split());input()
print(-(-~-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-1)/(K-1)))

Submission status: Accepted

Solution code:
import math
n,k = map(int,input().split())
al = 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()))

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()))
min = 0
x = a.index(1) +1
if n==k:
  print(1)
elif (n-k)%(k-1)==0:
  print(1 + (n-k)//(k-1))
else:
  print(2 + (n-k)//(k-1))

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
if n==k:
    print(1)
else:
    ans=0
    cnt=k
    for i in range(2,n):
        cnt+=(k-1)
        if cnt>=n:
            ans=i
            break
    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:
import math
n,k = map(int, input().split())
a= list(map(int, input().split()))
ans = math.ceil((n-k)/(k-1))

print(ans+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

aa=input()

a = n - k

num = -(-a // (k-1))

print(num+1)

Submission status: Accepted

Solution code:
#minimazation
n,m=map(int,input().split())
counter=0

lists=list(map(int,input().split()))
mini=min(lists)
for some in lists:
  if some!=mini:
    counter+=1
if counter%(m-1)==0:
  print(counter//(m-1))
else:
  print(counter//(m-1)+1)

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
a=[int(x) for x in range(N)]
for i in range(N):#1の場所を探す。他の数字は関係ない。
  if a[i]==1:
    p=i
L = p#1の左にある個数
R = N-p-1#1の右にある個数
count=L//(K-1)+R//(K-1)#一回の作業で(K-1)個変換できる
L_=L%(K-1)
R_=R%(K-1)#左右の端数を最初に処理したい。
if 0<L_+R_<=(K-1):
  count +=1
elif L_+R_>=K:
  count +=2
print(count)

Submission status: Accepted

Solution code:
import math
import numpy as np

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

# 最小値を見つけて、そこから何回の操作で全部最小値にできるか
# 最小値の場所をxとすると、math.ceil(x/k-1) + math.ceil(n-x/k-1)
# これだとkが大きいときに、違う答えが出ちゃう。一度に(k-1)個しか変えられないのは間違いない

#最小値の位置
x = np.argmin(a)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import fractions

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import ceil
    n,k=map(int,input().split())
    print(ceil((n-1)/(k-1)))
resolve()

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:
#!/usr/bin/env python3
import sys
from math import ceil
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
mod = 10**9+7

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

A_len = len(A)
A_len -= K
if A_len <= 0:
    print(1)
else:
    if A_len % (K-1) == 0:
        print(A_len // (K-1) + 1)
    else:
        print(A_len // (K-1) + 2)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-08 13:38:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, k, *a = (int(x) for x in sys.stdin.read().split())
    i = a.index(1)
    l = k - 1
    left, right = i, (n - 1) - i
    if left % l == 0:
        if right % l == 0:
            ans = left // l + right // l
        else:
            ans = left // l + right // l + 1
    else:
        if right % l  == 0:
            ans = left // l + 1 + right // l 
        else:
            if left % l + right % l > l:
                ans = left // l + right // l + 2
            else:
                ans = left // l + right // l + 1 
    
    print(ans)




if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, K = list(map(lambda x: int(x), input().split(' ')))
input()

import math
N -= K
print(int(math.ceil(N / (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):
    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()))
res = len(a) - a.count(min(a))
if res % (k - 1) != 0:
    ans = res // (k - 1) + 1
else:
    ans = res // (k - 1)
print(ans)

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+K-3)//(K-1))

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
ind = A.index(1)
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 = [int(a) for a in input().split()]
m = min(A)
ans = 0
i = 0
while i < N:
    if A[i] == m:
        i += 1
    else:
        ans += 1
        if min(A[i:i+K]) == m:
            i += K
        else:
            i += K - 1
print(ans)

Submission status: Accepted

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

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:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
print(-(-(n-1)//(k-1)))

Submission status: Accepted

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


def main():
    import math
    import collections
    import itertools

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

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

#idx=a_list.index(1)
#print(math.ceil(idx/(k-1)) + math.ceil((n-idx-1)/(k-1)))

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

Submission status: Accepted

Solution code:
import numpy as np
import statistics

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())
l=[int(i) for i in input().split()]
ind=l.index(min(l))
left=ind
right=n-ind-1 
from math import ceil 
print(ceil((left+right)/(k-1)))

Submission status: Accepted

Solution code:
N,K=map(int,input().split())
n=K
num=1
while not n>=N:
  n+=K-1
  num+=1
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

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

    id1 = a.index(1)

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

print(main())

Submission status: Accepted

Solution code:

if __name__ == '__main__':

	N = list(map(int,input().split()))
	input()
	n = N[0]
	m = N[1]

	cnt = 0
	while True:
		if m >= n:
			cnt += 1
			break
		n = n - m + 1
		cnt += 1

	print(cnt)

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

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()))
k-=1
for i in range(n):
    if a[i]==1:
        l=i+1
        break
n-=k+1
if n%k==0:
    print(n//k+1)
else:
    print(n//k+2)

Submission status: Accepted

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

Submission status: Accepted

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

import numpy as np 
ans = np.ceil((N-1)/(K-1))
print(int(ans))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
S = list(map(int,input().split()))
res = k
ans = 1
while res < n:
    res += 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-1)/(K-1)))

Submission status: Accepted

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

#idx = a.index(min(a))
#print(n // k + 1 )
ans = None
if n == k:
    ans = 1
else:
    if (n - 1) % (k - 1) != 0:
        ans = (n - 1) // (k - 1) + 1
    else:
        ans = (n - 1) // (k - 1)

print(ans)

Submission status: Accepted

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

total = 0
init = 1
cnt = 0
while total < N:
	if init == 1:
		total += K
	else:
		total += K - 1
	init = 0
	cnt += 1
	
print(cnt)

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

Submission status: Accepted

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

M-=1
N-=1
x=N//M
if N%M!=0:
  x+=1
print(x)

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:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
ary = list(map(int,input().split()))
n = N-M
ans = -(-n // (M-1))+1
print(ans)

Submission status: Accepted

Solution code:
import math

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

goal=min(A)
num=A.count(goal)

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

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

Submission status: Accepted

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

if((len(hoge)-1)/(k-1)%1==0):
  print((len(hoge)-1)//(k-1))
else:
  print(1+(len(hoge)-1)//(k-1))

Submission status: Accepted

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

Submission status: Accepted

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

# i = A.index(1)

# if i <= N - 1 or N - i <= K:
#     ans = N // (K - 1)
# else:
#     ans = (N // (K - 1)) + 1


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

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
Data = 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:
n,k = map(int, input().split())
a = list(map(int, input().split()))
point = 0
for i in range(n):
    if a[i]==1:
        point=i+1
x = point-1
xa = x%(k-1)
x = (-x)//(k-1)
x = -x
y = n-point
ya = y%(k-1)
y = (-y)//(k-1)
y = -y
ans = x+y
if xa>0 and ya>0 and xa+ya<k:
    ans-=1
print(ans)

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())
import math
A=[]*n
A[:]=map(int,input().split())
A=sorted(A)
if n==k:
  print(1)
else:
  print(1+int(math.ceil((n-k)/(k-1))))

Submission status: Accepted

Solution code:
# WIP (Two test cases remains WA, The fucking code)
import sys
sys_input = sys.stdin.readline

N, K = map(int, sys_input().split())
AAA = list(map(int, sys_input().split()))

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

n_remain = N
n_calc = 0
while n_remain > 0:
    n_remain += (-K+1)
    n_calc += 1
    if n_remain == K:
        n_calc += 1
        break

print(n_calc)

Submission status: Accepted

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

A_min_idx = A.index(min(A))

print(-(-(len(A)-1) // (k-1)) )

Submission status: Accepted

Solution code:
import sys
from math import ceil
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

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

Submission status: Accepted

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

ind = A.index(1)
ans = 0
if ind == 0 or ind == N - 1:
    ans = math.ceil((N - 1) / (K -1))
else:
    # 左部分
    ans += math.ceil((ind) / (K - 1))
    tmp = ind % (K - 1)
    # 右側部分
    if tmp == 0:
        ans += math.ceil((N - ind - 1) / (K - 1))
    else:
        ans += math.ceil((N - ind - 1 - K +  1 + tmp) / (K - 1))

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)

def inv(a,K,A):
    count=0
    count+=-(-a//(K-1))
    a=(K-1)*count
    count+=-(-(len(A)-1-a)//(K-1))
    return count


print(min(inv(a,K,A),inv(a,K,A[::-1])))

Submission status: Accepted

Solution code:
import math

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

# 最終的に全て1になるので、最初の1の場所からなるべく効率的に1を広めればよい
index_1 = A.index(1)

# 中央から進める場合と、1に近い方の端から順に進める場合
if K <= index_1 <= (N-1) - (K-1) -1:
    # 初手、長さKの区間のどこに1がくるか
    tmp = []
    for i in range(K):
        len_rest_left = index_1 - i
        len_rest_right = N - len_rest_left - K
        tmp.append(math.ceil(len_rest_left/(K-1)) + math.ceil(len_rest_right/(K-1)))
    ans = min(tmp) + 1
else:
    ans = math.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()))
if k >= n:
    print(1)
    exit()
count = 0
while n > 0:
    n -= k
    if n > 0:
        n += 1
    
    count += 1
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve():
    n,k = map(int, input().split())
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def solve():
    n,k = map(int, input().split())
    A = map(int, input().split())
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

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

Submission status: Accepted

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
one = A.index(1) +1
ans = float('inf')

for i in range(k):
    left = max(0,one-i)
    right = min(n,one+k-1 - i)
    num_l = max(0,int((left-1-0.1)//(k-1))+1)
    num_r = max(0,int((n - right-0.1)//(k-1))+1)
    ans = min(ans,num_r+num_l)

print(ans+1)

Submission status: Accepted

Solution code:
def test():
    m = 0
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = (n-1)/(k-1)
    while(m<b):
        m += 1
    print(m)


if __name__ == "__main__":
    test()

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
#101c
import math

N,K = map(int, input().split()) #K<=100
A_list = list(map(int, input().split()))

if len(A_list) <= K:
    print("1") #十分に短ければ1回で塗れる
elif len(A_list)%(K-1)==1:
    print(math.ceil(len(A_list)/(K-1))-1) #余りなく丁度塗れる場合
elif K==2:
    print(len(A_list)-1)
else:
    print(math.ceil(len(A_list)/(K-1)))

Submission status: Accepted

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

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

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()))
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())
A = list(map(int, input().split()))
# Nの中からK個中最大でK-1個だけ変えることができるので
# N >= T*(K-1) + 1となり、この式をTを求めるように式変形する（Tは試行回数）
##a/bの切り上げは(a-1)/b+1で求まる
T = (N-2) // (K-1)+1
print(T)

Submission status: Accepted

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
# Nの中からK個中最大でK-1個だけ変えることができるので
# N >= T*(K-1) + 1となり、この式をTを求めるように式変形する（Tは試行回数）
T = (N-2) // (K-1)+1
print(T)

Submission status: Accepted

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

minA = A.index(min(A))
ans = N

for i in range(K):
  count = 1
  left = minA - i
  right = minA + K - 1 - i
  #一回でK-1個を最小値にすることができる。
  if left >= 0:
    count += left // (K - 1)
    if left % (K - 1) != 0:
      count += 1
  if right != N -1:
    count += (N - right - 1) // (K - 1)
    if (N - right + 1) % (K - 1) != 0:
      count += 1
  if (left >= 0) and (right < N):
    ans = min(count, ans)
  #print(left, right, count)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k = map(int, input().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())
a = list(map(int, input().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:
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,*a = map(int, open(0).read().split())
print((n+k-3)//(k-1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil

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

print(1 + 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-1)/(K-1)))

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    from math import ceil
    print(ceil((N-1)/(K-1)))
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    A = (int(i) for i in input().split())
    from math import ceil
    print(ceil((N-1)/(K-1)))
if __name__ == '__main__':
    main()