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: Wrong Answer

Solution code:

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

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

l = start
r = n - start -1

if l == 0:
    numl = 0
elif l <= k:
    numl = 1
elif l % (k-1) == 0:
    numl = l // (k-1)
else:
    numl = (l // (k-1)) + 1

if r == 0:
    numr = 0
elif r <= k:
    numr = 1
elif r % (k-1) == 0:
    numr = r // (k-1)
else:
    numr = (r // (k-1)) + 1

print(numl + numr)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re, os

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

sys.setrecursionlimit(10 ** 9)


def main():
    N, K = LIST()  # N = 4, K = 3
    A = LIST()  # A = [2, 3, 1, 4]
    count = 0
    min_index = A.index(min(A))
    flag_left = False
    flag_right = False
    check_left = min_index
    check_right = min_index

    while not flag_left :
        if check_left <= 0:
            flag_left = True
        else:
            check_left -= K - 1
            count += 1

    while not flag_right:
        if check_right >= N - 1:
            flag_right = True
        else:
            check_right += K - 1
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k,*l=map(int,open(0).read().split());i=l.index(1);k-=1;print(i//k+(n-i-1)//k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
ichi_index = A_list.index(1)
pre = ichi_index - 0 + 1
bef = N - 1 - ichi_index + 1
#print(pre,bef)
result = pre // (K-1) + bef // (K-1)
'''
if ichi_index != 0:
    if pre % K == 0:
        if bef % K == 0:
            result = pre // (K-1) + bef // (K-1)
        else:
            result = pre // (K-1) + bef // (K-1) + 1
    else:
        if bef % K == 0:
            result = pre // (K-1) + 1 + bef // (K-1)
        else:
            result = pre // (K-1) + 1 + bef // (K-1) + 1
else:
    if bef % K == 0:
        result = bef // (K-1)
    else:
        result = bef // (K-1) + 1
'''
print(result)

Submission status: Wrong Answer

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

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

dis = A.index(1)
left = dis
right = N - 1 - dis
ans = -((-left)//(K-1))+(-((-right)//(K-1)))

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    n = S()
    num = sum(map(int, n))
    n = int("".join(n))
    print(["Yes", "No"][n % num > 0])
    return

#C
def C():
    n, k = LI()
    a = LI()
    print((n - k) // (k - 1) + 1)
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    n = S()
    num = sum(map(int, n))
    n = int("".join(n))
    print(["Yes", "No"][n % num > 0])
    return

#C
def C():
    n, k = LI()
    a = LI()
    one = a.index(1)
    if k == n:
        print(1)
        return
    ans = 0
    i = one
    while i < n-1:
        ans += 1
        i += k - 1
    i = one
    while i > 0:
        ans += 1
        i -= k - 1
    print(ans)
    return

#D
def D():
    return


#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

x=np.argmin(a)+1
ans1=-(-(x-1)//(k-1))
ans2=-(-(n-x)//(k-1))
print(ans1+ans2)

Submission status: Wrong Answer

Solution code:
N, K = map(int, raw_input().split(' '))
S = map(int, raw_input().split(' '))
if N <= K:
  print 1
else:
  t = 0
  for i in range(len(S)):
    if S[i] == 1:
      t = i
      break
  t2 = t
  ans = 0
  while t > 0:
    t -= (K-1)
    ans += 1
  while t2 < len(S):
    t2 += (K-1)
    ans += 1
  print ans

Submission status: Wrong Answer

Solution code:
import math

b, c  = [int(a) for a in input().split()]
print (math.ceil(b / ((c - 1) * 1.0)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if K >= N:
    print(1)

else:
    print(int(-(-N/(K-1))))

Submission status: Wrong Answer

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

min_idx = 0
for idx in range(N):
  if A[idx] < A[min_idx]:
    min_idx = idx
ans = 0
if (N-min_idx)%(K-1) == 0:
  ans += (N-min_idx)//(K-1)
else:
  ans += (N-min_idx)//(K-1)+1
if min_idx%(K-1) == 0:
  ans += min_idx//(K-1)
else:
  ans += min_idx//(K-1) + 1
print(ans)

Submission status: Wrong Answer

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

p1 = A.index(1) + 1

l = (p1-1) // (K-1)
r = (N-p1) // (K-1)
amari = N - l*(K-1) - r*(K-1)

if N <= 2*K-1:
    ans = 2
elif amari <= K:
    ans = l + r + 1
else:
    ans = l + r + 2

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

Submission status: Wrong Answer

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

#最小値のインデックスを見る
min_idx = A.index(min(A))

if min_idx < K:
    min_idx = K - 1
#最小値が左端にある場合，ずらして考えればいいよね

elif (N - 1 - min_idx) < K:
    min_idx = N - K
#最小値が右端にある場合，ずらして考えればいいよね

else:
    pass

left_step = min_idx //(K - 1)
if(min_idx %(K - 1) != 0):
    left_step += 1

right_step = (N - 1 - min_idx) // (K - 1)
if((N - 1 - min_idx) % (K - 1) != 0):
    right_step += 1

print(left_step + right_step +1 )

Submission status: Wrong Answer

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

#最小値のインデックスを見る
min_idx = A.index(min(A))

if min_idx < K:
    min_idx = K - 1
#最小値が左端にある場合，ずらして考えればいいよね

elif (N - 1 - min_idx) < K:
    min_idx = N - K
#最小値が右端にある場合，ずらして考えればいいよね

else:
    pass

left_step = min_idx //(K - 1)
if(min_idx %(K - 1) != 0):
    left_step += 1

right_step = (N - 1 - min_idx) // (K - 1)
if((N - 1 - min_idx) % (K - 1) != 0):
    right_step += 1

print(left_step + right_step)

Submission status: Wrong Answer

Solution code:
import math
N, K = list(map(int, input().strip().split(' ')))
A = list(map(int, input().strip().split(' ')))
min_idx = A.index(min(A))
if min_idx < K:
    min_idx = K - 1
elif (N - 1 - min_idx) < K:
    min_idx = N - K
else:
    pass
left_step = math.ceil(min_idx / (K - 1))
right_step = math.ceil((N - 1 - min_idx) / (K - 1))
print(left_step + right_step)

Submission status: Wrong Answer

Solution code:
import math
N, K = list(map(int, input().strip().split(' ')))
A = list(map(int, input().strip().split(' ')))
min_idx = A.index(min(A))
if min_idx < K:
    min_idx = K - 1
elif (N - 1 - min_idx) < K:
    min_idx = min_idx - ((K - 1) - (N - 1 - min_idx))
else:
    pass
left_step = math.ceil(min_idx / (K - 1))
right_step = math.ceil((N - 1 - min_idx) / (K - 1))
print(left_step + right_step)

Submission status: Wrong Answer

Solution code:
import math

N, K = list(map(int, input().strip().split(' ')))
A = list(map(int, input().strip().split(' ')))
min_idx = A.index(min(A))
left_step = math.ceil(min_idx / (K - 1))
right_step = math.ceil((N - 1 - min_idx) / (K - 1))
print(left_step + right_step)

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

if(N==K):
    ans = 1
elif(N!=K):
    ans = N//(K-1)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 1回の操作ではK-1個の数を1にできる、変えなくてはいけない数はN-1個　その天井をとればok
import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = math.floor((N - 1) / (K - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

pos1=A.index(1)
l=pos1
r=N-pos1-1
numl=math.ceil(l/(K-1))
numr=math.ceil(r/(K-1))
ans=numl+numr

if N==K:
    ans=1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
min_number = min(A)
min_index = A.index(min_number)
count = 0

left_count = math.ceil((min_index)/(K-1))
right_count = math.ceil((len(A)-1-min_index)/(K-1))

print(left_count+right_count)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
min_number = min(A)
left = A.index(min_number)
right =  A.index(min_number)
count = 0

while len(list(set(A))) > 1:
  if left > 0:
    next_left = left-K+1 if left-K+1 >= 0 else 0
    A[next_left:left+1] = [min_number]*len(A[next_left:left+1])
    left = left-K+1
    count+=1
  
  if right < len(A)-1:
    next_right = right+K-1 if right+K-1 <= len(A)-1 else len(A)-1
    A[right:next_right+1] = [min_number]*len(A[right:next_right+1])
    right = right+K-1
    count+=1

print(count)

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
min_number = min(A)
left = A.index(min_number)
right =  A.index(min_number)
count = 0

while len(list(set(A))) > 1:
  if left > 0:
    next_left = left-K+1 if left-K+1 >= 0 else 0
    A[next_left:left+1] = [min_number]*len(A[next_left:left+1])
    left = left-K+1
    count+=1
    print(A)
  
  if right < len(A)-1:
    next_right = right+K-1 if right+K-1 <= len(A)-1 else len(A)-1
    A[right:next_right+1] = [min_number]*len(A[right:next_right+1])
    right = right+K-1
    count+=1
    print(A)

print(count)

Submission status: Wrong Answer

Solution code:
n, k = map(int, raw_input().split())
arr = map(int, raw_input().split())
print max(1, n / (k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

#print(P)
ans=0
ans+=math.ceil(P/(K-1))
#print(ans)
ans+=math.ceil((N-1-P)/(K-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
left = data.index(1)
right = N - data.index(1) - 1
if left != 0:
  ans += max(math.ceil(left / (K-1)),1)

if right != 0:
  ans += max(math.ceil(right / (K-1)),1)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
left = data.index(1)
right = N - data.index(1) - 1
if left != 0:
  ans += max(round(left / (K-1)),1)
if right != 0:
  ans += max(round(right / (K-1)),1)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
left = data.index(1)
right = N - data.index(1) - 1
if left != 0:
  ans += max((left // (K-1)),1)
if right != 0:
  ans += max((right // (K-1)),1)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
left = data.index(1)
right = N - data.index(1) - 1
ans = max((left // (K-1)),1) + max((right // (K-1)),1)
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
left = data.index(1)
right = N - data.index(1) - 1
ans = (left // (K-1)) + (right // (K-1)) + 2
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
left = data.index(1) + 1
right = N - data.index(1) 
ans = (left // (K-1)) + (right // (K-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
for i in range(N):
    if Alist[i]==1:
        cnt = i+1
        break

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

Submission status: Wrong Answer

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

cnt = 0
for i in range(N):
    if Alist[i]==1:
        cnt = i+1
        break

if cnt == 1 and K==2:
    print((N-cnt+1) // (K-1))
elif cnt == N and K==2:
    print((cnt) // (K-1))
elif K==2:
    print(N-1)
else:
    print((cnt) // (K-1) + (N-cnt+1) // (K-1))

Submission status: Wrong Answer

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

cnt = 0
for i in range(N):
    if Alist[i]==1:
        cnt = i+1
        break

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

import math

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

def func1(lst,value):
    for i,x in enumerate(lst):
        if x == value:
            return i
index = func1(A,1)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
a_cnt = Counter(a)
a_cnt_common = a_cnt.most_common()[0][1]
if n-k > 1:
    print(n-k-1)
else:
    print(n-k+1)

Submission status: Wrong Answer

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

l = an.index(min(an))
r = n- l -1
from math import ceil
print(ceil(r/(k-1)) + ceil(l/(k-1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

if a_lis.index(1) + 1 <= K or N - a_lis.index(1) <= K:
    if K == 2:
        print(N - 1)
        sys.exit()
    print(math.ceil((N - K) / (K - 1)) + 1)
    sys.exit()
else:
    if K == 2:
        print(N - 1)
        sys.exit()
    if (N - K) % (K - 1) == 0:
        first = math.ceil(N / K)
        print(first)
        sys.exit()
    second = math.ceil(a_lis.index(1) / (K - 1)) + math.ceil((N - a_lis.index(1) - 1) / (K - 1))
    #print(min(first, second))
    print(second)
    sys.exit()

Submission status: Wrong Answer

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

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

if a_lis.index(1) + 1 <= K or N - a_lis.index(1) <= K:
    print(math.ceil((N - K) / (K - 1)) + 1)
    sys.exit()
else:
    if (N - K) % (K - 1) == 0:
        first = math.ceil(N / K)
        print(first)
        sys.exit()
    second = math.ceil(a_lis.index(1) / (K - 1)) + math.ceil((N - a_lis.index(1) - 1) / (K - 1))
    #print(min(first, second))
    print(second)
    sys.exit()

Submission status: Wrong Answer

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

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

if a_lis.index(1) + 1 <= K or N - a_lis.index(1) <= K:
    print(math.ceil((N - K) / (K - 1)) + 1)
    sys.exit()
else:
    first = math.ceil(N / K)
    second = math.ceil(a_lis.index(1) / (K - 1)) + math.ceil((N - a_lis.index(1) - 1) / (K - 1))
    print(min(first, second))
    sys.exit()

Submission status: Wrong Answer

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

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

if a_lis.index(1) + 1 <= K or N - a_lis.index(1) <= K:
    print(math.ceil((N - K) / (K - 1)) + 1)
    sys.exit()
else:
    print(math.ceil(a_lis.index(1) / (K - 1)) + math.ceil((N - a_lis.index(1) - 1) / (K - 1)))
    sys.exit()

Submission status: Wrong Answer

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

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

if a_lis.index(1) < K or N - a_lis.index(1) - 1 < K:
    print(math.ceil((N - K) / (K - 1)) + 1)
    sys.exit()
else:
    print(math.ceil(a_lis.index(1)) / (K - 1) + math.ceil((N - a_lis.index(1) - 1) / (K - 1)))
    sys.exit()

Submission status: Wrong Answer

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

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

if a_lis.index(1) < K or N - a_lis.index(1) - 1 < K:
    print(math.ceil((N - K) / (K - 1)) + 1)
    sys.exit()

if a_lis.index(1) == 0:
    left = 0
elif a_lis.index(1) < K:
    left = 1
else:
    if K == 2:
        left = a_lis.index(1)
    else:
        left = math.ceil((a_lis.index(1)) / (K - 1))

if a_lis.index(1) == N - 1:
    right = 0
elif N - a_lis.index(1) - 1 < K:
    right = 1
else:
    if K == 2:
        right = N - a_lis.index(1) - 1
    else:
        right = math.ceil((N - a_lis.index(1) - 1) / (K - 1))
print(right + left)

Submission status: Wrong Answer

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

if a_lis.index(1) == 0:
    left = 0
elif a_lis.index(1) < K:
    left = 1
else:
    if K == 2:
        left = (a_lis.index(1)) // (K - 1) + (a_lis.index(1)) % (K - 1)
    else:
        left = math.ceil((a_lis.index(1)) / (K - 1))

if a_lis.index(1) == N - 1:
    right = 0
elif N - a_lis.index(1) - 1 < K:
    right = 1
else:
    if K == 2:
        right = (N - a_lis.index(1) - 1) // (K - 1) +  (N - a_lis.index(1) - 1) % (K - 1)
    else:
        right = math.ceil((N - a_lis.index(1) - 1) / (K - 1))
print(right + left)

Submission status: Wrong Answer

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

if a_lis.index(1) == 0:
    left = 0
elif a_lis.index(1) < K:
    left = 1
else:
    if K == 2:
        left = (a_lis.index(1)) // (K - 1) + (a_lis.index(1)) % (K - 1)
    else:
        left = (a_lis.index(1)) // (K - 1) + (a_lis.index(1)) % (K - 1)

if a_lis.index(1) == N - 1:
    right = 0
elif N - a_lis.index(1) - 1 < K:
    right = 1
else:
    if K == 2:
        right = (N - a_lis.index(1) - 1) // (K - 1) +  (N - a_lis.index(1) - 1) % (K - 1)
    else:
        right = (N - a_lis.index(1) - 1) // (K - 1) +  (N - a_lis.index(1) - 1) % (K - 1)
print(right + left)

Submission status: Wrong Answer

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

if a_lis.index(1) == 0:
    left = 0
elif a_lis.index(1) < K:
    left = 1
else:
    if K == 2:
        left = (a_lis.index(1)) // (K) + (a_lis.index(1)) % (K)
    else:
        left = (a_lis.index(1)) // (K - 1) + (a_lis.index(1)) % (K - 1)

if a_lis.index(1) == N - 1:
    right = 0
elif N - a_lis.index(1) - 1 < K:
    right = 1
else:
    if K == 2:
        right = (N - a_lis.index(1) - 1) // K +  (N - a_lis.index(1) - 1) % K
    else:
        right = (N - a_lis.index(1) - 1) // (K - 1) +  (N - a_lis.index(1) - 1) % (K - 1)
print(right + left)

Submission status: Wrong Answer

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

if a_lis.index(1) == 0:
    left = 0
elif a_lis.index(1) < K:
    left = 1
else:
    if K == 2:
        left = (a_lis.index(1) + 1) // (K) + (a_lis.index(1) + 1) % (K)
    else:
        left = (a_lis.index(1) + 1) // (K - 1) + (a_lis.index(1) + 1) % (K - 1)

if a_lis.index(1) == N - 1:
    right = 0
elif N - a_lis.index(1) - 1 < K:
    right = 1
else:
    if K == 2:
        right = (N - a_lis.index(1)) // K +  (N - a_lis.index(1)) % K
    else:
        right = (N - a_lis.index(1)) // (K - 1) +  (N - a_lis.index(1)) % (K - 1)
print(right + left)

Submission status: Wrong Answer

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

if a_lis.index(1) == 0:
    left = 0
elif a_lis.index(1) < K:
    left = 1
else:
    left = (a_lis.index(1) + 1) // (K - 1) + (a_lis.index(1) + 1) % (K - 1)

if a_lis.index(1) == N - 1:
    right = 0
elif N - a_lis.index(1) - 1 < K:
    right = 1
else:
    right = (N - a_lis.index(1) - 1) // (K - 1) +  (N - a_lis.index(1) - 1) % (K - 1)
print(right + left)

Submission status: Wrong Answer

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

if a_lis.index(1) == 0:
    left = 0
elif a_lis.index(1) < K:
    left = 1
else:
    left = a_lis.index(1) + 1 - K + 1

if a_lis.index(1) == N - 1:
    right = 0
elif N - a_lis.index(1) - 1 < K:
    right = 1
else:
    right = N - a_lis.index(1) - 1 - K + 1
print(right + left)

Submission status: Wrong Answer

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

ind = A.index(1)

if (ind - (K-1) < 0) or (ind + (K-1) > N-1) :
    ans = 1 + (N-K)//(K-1) + ((N-K)%(K-1)!=0)
else :
    left = ind
    right = N-ind-1
    ans = left//(K-1) + right//(K-1) + (left % (K-1) != 0) + (right % (K-1) != 0)

print(ans)

Submission status: Wrong Answer

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

ind = A.index(1)

left = ind
right = N-ind-1

if (left < K) or (right < K) :
    ans = 1 + (N-K)//(K-1) + ((N-K) % (K-1) != 0)
else :
    ans = left//(K-1) + right//(K-1) + (left % (K-1) != 0) + (right % (K-1) != 0)

print(ans)

Submission status: Wrong Answer

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

ind = A.index(min(A))

left = ind
right = N-ind-1

ans = left//(K-1) + (left % (K-1) != 0) + right//(K-1) + (right % (K-1) != 0)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
c=a.count(m) 
d=n-c 
ans=math.floor(n/(k-1))
print(ans)

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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


for i in range(len(A)):
    if A[i] == 1:
        point = i

left = point
right = N - point - 1

ans = 0

if left % (K-1) == 0:
    ans += left // (K - 1)
else:
    ans += left // (K - 1) + 1

if right % (K-1) == 0:
    ans += right // (K - 1)
else:
    ans += right // (K - 1) + 1


print (ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
for i in range(n):
  if l[i]==1:
    a=i+1
left=a-1
right=n-a
if left%(k-1)==0:
  lcnt=left//(k-1)
else:
  lcnt=left//(k-1)+1
if right%(k-1)==0:
  rcnt=right//(k-1)
else:
  rcnt=right//(k-1)+1
print(lcnt+rcnt)

Submission status: Wrong Answer

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

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

print(N // (K - 1))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
Amin = 10000000
ii = -1
ans = 0
for i,a in enumerate(A):
    if Amin > a:
        Amin = a
        ii = i

left = ii
right = ii
for i in range(N):
    if left > 0:
        left -= K-1
        ans += 1
    if right < N - 1:
        right += K-1
        ans += 1
print(ans)

Submission status: Wrong Answer

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

if n == k:
  print(1)
else:
  c = 1
  a = n-k
  while a > 0:
    c = +1
    a -= k-1
  print(c)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

indx = A.index(1)

if indx == 0 or indx == (N - 1):
    print(ceil((N-1)/(K-1)))
    exit()

ans1 = ceil(indx / (K-1))
ans2 = ceil((N - indx - 1) / (K-1))
print(ans1 + ans2)

Submission status: Wrong Answer

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

def solve(l,k):
    if l%(k-1)==0:
        return l//(k-1)
    else:
        return l//(k-1)+1

ind = a.index(1)+1

a = solve(ind-1,k)
b = solve(n-ind,k)
print(a+b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
n ,k = map(int, input().split())
a = list(map(int, input().split()))
mn = min(a)
b = []

frm = 0
for i in range(n):
  if a[i] == mn:
    b.append(i-frm)
    frm = i
b.append(n-1-frm)

ans = 0
for i in b: ans += ceil(i/(k-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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