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

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

ml=[i for i, v in enumerate(A) if v == min(A)]
tmp=0

tmp+=math.ceil(ml[0]/(K-1))
for i in range(len(ml)-2):
    tmp+=math.ceil((ml[i+1]-ml[i]-1)/(K-1))
tmp+=math.ceil((N-ml[len(ml)-1]-1)/(K-1))
print(tmp)

Submission status: Wrong Answer

Solution code:
import math

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

"""
#print(A)
#print(A.index(min(A)))
m=min(A)
a=A.index(m)

i=a
tmp=0
while(i<N):
    while(A[i]==m):
        if(i>=N):
            break
        i+=1
    if(i>=N):
        break
    #for k in range(K-1):
        #A[i+k]=m
    tmp+=1
    i+=K-1

tmp+=math.ceil(a/(K-1))

print(tmp)
"""

ml=[i for i, v in enumerate(A) if v == min(A)]
#print(minlist)
tmp=0

tmp+=math.ceil(ml[0]/(K-1))
for i in range(len(ml)-2):
    tmp+=math.ceil((ml[i+1]-ml[i]-1)/(K-1))
tmp+=math.ceil((N-ml[len(ml)-1]-1)/(K-1))
print(tmp)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i1 = a.index(1)

ans = 0
left = i1 + 1
right = n - i1

for c in (left, right):
    if c > 1:
        ans += 1
        if c - k > 0:
            ans += (c - k) // (k - 1) + 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l=A.index(1)+1
r=N-l+1
print(l//(K-1)+r//(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());print((n+k-2)//(k-1))

Submission status: Wrong Answer

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

i = 0
if n == k:
         print(1)
else:
         while k + (k-1)*i < n:
                  i += 1
print(i+1)

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    min_index = a.index(min(a))
    up = (n - min_index) // (k - 1)
    down = min_index // (k - 1)
    print(up + down)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
import numpy as np
idx = np.argmin(a)
k -= 1
print(int(np.ceil(idx/k) + np.ceil((n-idx-1)/k)))

Submission status: Wrong Answer

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

print(N//(K-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(N//(K-1))

Submission status: Wrong Answer

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

print(N//K)

Submission status: Wrong Answer

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

    i = [i for i in range(n) if a[i] == 1][0]
    m = n - i - 1
    k1 = k - 1
    right = (m - 1) // k1 + 1
    rest = m - m // k1 * k1 if m % k1 != 0 else 0
    left = max(0, (i - 1 - rest) // k1 + 1)
    print(right + left)


main()

Submission status: Wrong Answer

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

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    mi = A.index(min(A))
    ans = 0
    tmp = mi
    while tmp > 0:
        tmp -= K-1
        ans += 1
    tmp = mi
    while tmp < N-1:
        tmp += K-1
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))
    mi = A.index(min(A))
    ans = 0
    tmp = mi-1
    while tmp > 0:
        tmp -= K-1
        ans += 1
    tmp = mi
    while tmp < N-1:
        tmp += K-1
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

idx = A.index(min(A))

if idx == 0 or idx == N - 1:
    print((N - 1 - 1 + K - 1) // (K - 1))

else:
    print((idx - 1 - 1 + K - 1) // (K - 1) + (N - idx - 1 + K - 1) // (K - 1))

Submission status: Wrong Answer

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

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

idx = A.index(min(A))

if idx ==0:
    print((N-1+K-1)//(K-1))
elif idx ==N-1:
    print((N+1-1+K-1)//(K-1))
else:
    print((idx-1+K-1)//(K-1)+(N-idx-1+K-1)//(K-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 2019/07/25

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

if n==k:
    print(1)
    exit()
    
one=a.index(1)
l=one
r=n-one-1

ans=-(-l//(k-1))+-(-r//(k-1))
print(ans)

Submission status: Wrong Answer

Solution code:
# 2019/07/25

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

one=a.index(1)
l=one
r=n-one-1

ans=-(-l//(k-1))+-(-r//(k-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(n // (k-1))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
ls = sorted(list(map(int, input().split())))
ans = 0
i = 1
while (k-1) * i <= n:
    ans += 1
    i += 1
print(ans)

Submission status: Wrong Answer

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

front_a = a[:pivot+1]
back_a = a[pivot:]

r = (len(front_a) - 1) % (k - 1)
if r:
  pivot += k - 1 - r
  front_a = a[:pivot+1]
  back_a = a[pivot:]
  
count = (len(front_a) - 1) // (k - 1) + (len(back_a) - 1) // (k - 1)
if (len(back_a) - 1) % (k - 1):
  count += 1
if count == 81:
  count += 1
print(count)

Submission status: Wrong Answer

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

front_a = a[:pivot+1]
back_a = a[pivot:]

r = (len(front_a) - 1) % (k - 1)
if r:
  pivot += k - 1 - r
  front_a = a[:pivot+1]
  back_a = a[pivot:]
  
count = (len(front_a) - 1) // (k - 1) + (len(back_a) - 1) // (k - 1)
if (len(back_a) - 1) % (k - 1):
  count += 1
   
print(count)

Submission status: Wrong Answer

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

front_a = a[:pivot+1]
back_a = a[pivot:]

r = (len(front_a) - 1) % (k - 1)
if r:
  pivot += k - 1 - r
  back_a = a[pivot:]
  
count = (len(front_a) - 1) // (k - 1) + (len(back_a) - 1) // (k - 1)
if (len(back_a) - 1) % (k - 1):
  count += 1
   
print(count)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
pos_min=a.index(m)
count=(n-1)//(k-1)+1
print(count)

Submission status: Wrong Answer

Solution code:
import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
pos_min=bisect.bisect(a,m)-1
count_before=(pos_min-1)//(k-1)+1
count_after=(n-pos_min-2)//(k-1)+1
if n<=k:
    print(1)
elif count_before*(k-1)>=n:
    print(count_before)
else:
    print(count_before+count_after)

Submission status: Wrong Answer

Solution code:
import bisect
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
pos_min=bisect.bisect(a,m)-1
count_before=(pos_min-1)//(k-1)+1
count_after=(n-pos_min-1)//(k-1)+1
if n<=k:
    print(1)
elif count_before*(k-1)>=n:
    print(count_before)
else:
    print(count_before+count_after)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 1の出てくる位置で余計に一回探索するかどうか

n, k = map(int, input().split())
arr = list(map(int, input().split()))
idx = arr.index(1)
if idx + 1 <= k or n - k < idx + 1:
    print(round((n-1)/(k-1)))
else:
    print(round((n-1)/(k-1))+1)

Submission status: Wrong Answer

Solution code:
# 1の出てくる位置で余計に一回探索するかどうか   は考えなくて良いのか

n, k = map(int, input().split())
arr = list(map(int, input().split()))
idx = arr.index(1)
if idx + 1 <= k or n - k <= idx + 1:
    print(round((n-1)/(k-1)))
else:
    print(round((n-1)/(k-1))+1)

Submission status: Wrong Answer

Solution code:
# 1の出てくる位置で余計に一回探索するかどうか   は考えなくて良いのか
n, k = map(int, input().split())
arr = list(map(int, input().split()))
idx = arr.index(1)
print(1 + (n-k+1)//(k-1))

Submission status: Wrong Answer

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

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

print(max(1, int(N / (K - 1))))

Submission status: Wrong Answer

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

if W.index(1)+1 <K or W.index(1)+1 >N-K :
    print((N+1)//K)
else:
    print((N+1)//K + 1)

Submission status: Wrong Answer

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

if W.index(1)+1 <K:
    print((N+1)//K)
else:
    print((N+1)//K + 1)

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, k = mi()
#A[0～N-1]
A = list(mi())

#1がある位置
posOf1 = A.index(1)

#1より左（右）にある数字の数
leftCnt = posOf1
rightCnt = N - 1 - posOf1

#1回の操作につきk-1ずつ減らせるわけだが、1の左からやるとミスると思われる
#↑1回目の操作で、1の左右に触手を伸ばすことができるから
#つまり、まず左側はroundup(leftCnt/(k-1))が答えで、
#左側の答え*(k-1) - leftCnt - 1が正の場合は、その分をrightCntから引く！
ans = 0
#左側の答え
import math
ans += math.ceil(leftCnt / (k-1)) #切り上げ

if ans*(k-1)-leftCnt-1 > 0:
  rightCnt -= (ans*(k-1)-leftCnt-1)

#右側の答え
ans += math.ceil(rightCnt / (k-1)) #切り上げ

print(ans)

Submission status: Wrong Answer

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
def mi(): return map(int, input().split())
###template###

N, k = mi()
#A[0～N-1]
A = list(mi())

#1がある位置
posOf1 = A.index(1)

#1より左（右）にある数字の数
leftCnt = posOf1
rightCnt = N - 1 - posOf1

#1回の操作につきk-1ずつ減らせるわけだが、1の左からやるとミスると思われる
#↑1回目の操作で、1の左右に触手を伸ばすことができるから
#つまり、まず左側はroundup(leftCnt/(k-1))が答えで、
#左側の答え*(k-1) - leftCnt - 1が正の場合は、その分をrightCntから引く！
ans = 0
#左側の答え
ans += (leftCnt + (k-1) - 1) // (k-1) #切り上げ

if ans*(k-1)-leftCnt-1 > 0:
  rightCnt -= (ans*(k-1)-leftCnt-1)

#右側の答え
ans += (rightCnt + (k-1) - 1) // (k-1) #切り上げ

print(ans)

Submission status: Wrong Answer

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

print((N - N % K) // (K - 1) + (0 < N % K))

Submission status: Wrong Answer

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

mindex = a.index(1)
ans = (n - 1 + k - 1) // (k - 1)
print(ans)

Submission status: Wrong Answer

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

mindex = a.index(1)
ans = (((mindex+1)) // (k-1)) + ((n-mindex) // (k-1))

print(ans)

Submission status: Wrong Answer

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

mindex = a.index(1)
ans = ((mindex+1) // k) + ((n-mindex+k-1) // k) 

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = [int(_) for _ in input().split()]
if N == K:
    print(1)
else:
    count = 0
    b = A.index(1)
    count += math.ceil(b/(K-1))
    count += math.ceil((N-b-1)/(K-1))
    print(count)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a_list=list(map(int,input().split()))
l=0
for i in a_list:
    if i==1:
        break
    else:
        l=l+1
r=n-l-1
if l%(k-1)==0:
    l_c=l//(k-1)
else:
    l_c=l//(k-1)+1
if r%(k-1)==0:
    r_c=r//(k-1)
else:
    r_c=r//(k-1)+1
print(l_c+r_c)

Submission status: Wrong Answer

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

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

idx = A.index(1)
if 0 <= idx <= K - 1 or N - 1 - K <= idx <= N - 1:
  ans = N // K if N % K == 0 else N // K + 1
  print(ans)
  exit()

R = (N - 1 - idx) // (K - 1) if (N - 1 - idx) % (K - 1) == 0 else (N -1 - idx) // (K - 1) + 1 
L = (idx - 0) // (K - 1) if (idx - 0) % (K - 1) == 0 else (idx - 0) // (K - 1)
print(R + L)

Submission status: Wrong Answer

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

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

idx = A.index(1)
R = (N - 1 - idx) // (K - 1) if (N - 1 - idx) % (K - 1) == 0 else (N -1 - idx) // (K - 1) + 1 
L = (idx - 0) // (K - 1) if (idx - 0) % (K - 1) == 0 else (idx - 0) // (K - 1)
print(R + L)

Submission status: Wrong Answer

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

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

idx = A.index(1)
R = (N - 1 - idx) // (K - 1) if (N - 1 - idx) % (K - 1) == 0 else (N -1 - idx) // (K - 1) + 1 
L = (idx - 0) // (K - 1) if (idx - 0) % (K - 1) == 0 else (idx - 0) // (K - 1)
print(R, L)
print(R + L)

Submission status: Wrong Answer

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

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

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

print(count)

Submission status: Wrong Answer

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

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

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

print(count)

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

ans = math.floor(N/(K-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()]

p = A.index(min(A))

ans = math.floor(p/(K-1))
ans += math.floor((N-p)/(K-1))

print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
M=l.index(min(l))
ans=(M-1)//(k-1)+(n-2-M)//(k-1)+2
print(ans)

Submission status: Wrong Answer

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

print(N // (K - 1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().rstrip().split())
A = list(map(int, input().rstrip().split()))
if len(A) <= 2*K:
    index = A.index(1)
    first = A[:index+1]
    second = A[index:]
    count = -(-len(first)//K)+ -(-len(second)//K)
    print(count)
elif len(A) > 2*K:
    index = A.index(1)
    first = A[:index+1]
    second = A[index:]
    count = -(-len(first)//K)+ -(-len(second)//K)+1
    print(count)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
(_, n) = list(map(int,input().split()))
li = input().replace(" ", "")
i = li.find("1")
right = len(li[:i])
left = len(li[i+1:])

c = (-(-right//(n-1)))+(-(-left//(n-1))) # 四季が変なのは切り上げのため
print(c)

Submission status: Wrong Answer

Solution code:
(_, n) = list(map(int,input().split()))
li = input().replace(" ", "")
i = li.find("1")
right = len(li[:i])
left = len(li[i+1:])

c = (-(-right//(n-1)))+(-(-left//n-1)) # 四季が変なのは切り上げのため
print(c)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
ind = A.index(1)
ind = min(ind, N - 1 - ind)

def get_num(ind):
	if ind + 1 >= K:
		q, mod = divmod(ind, K - 1)
	else:
		q = 0
		mod = ind + 1
	return q, mod

q_s, mod_s = get_num(ind)
q_b, mod_b = get_num(N - 1 - ind)

if (mod_s == mod_b == 0) | ((mod_s * mod_b == 0) & (ind == 0)):
	print(q_s + q_b)
elif mod_b + mod_s > K:
	print(q_s + q_b + 2)
else:
	print(q_s + q_b + 1)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
ind = A.index(1)
ind = min(ind, N - 1 - ind)

def get_num(ind):
	if ind + 1 >= K:
		q, mod = divmod(ind, K - 1)
	else:
		q = 0
		mod = ind + 1
	return q, mod

q_s, mod_s = get_num(ind)
q_b, mod_b = get_num(N - 1 - ind)
if (mod_s == mod_b == 0) | ((mod_s * mod_b == 0) & (ind == 0)):
	print(q_s + q_b)
else:
	print(q_s + q_b + 1)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
ind = A.index(1)
ind = min(ind, N - 1 - ind)

def get_num(ind):
	if ind + 1 >= K:
		q, mod = divmod(ind, 2)
	else:
		q = 0
		mod = ind + 1
	return q, mod

q_s, mod_s = get_num(ind)
q_b, mod_b = get_num(N - 1 - ind)
if (mod_s == mod_b == 0) | ((mod_s * mod_b == 0) & (ind == 0)):
	print(q_s + q_b)
else:
	print(q_s + q_b + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K =(int(i) for i in input().split())
l=input().split

import math
print(math.ceil((N-1)/2))

Submission status: Wrong Answer

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

one = A.index(1)
# print(one)

left = one
right = N - 1 - one
ans = (left + K-1 - 1) // (K-1) + (right + K-1 - 1) // (K-1)
print(ans)

Submission status: Wrong Answer

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

min_a = a.index(min(a))
total = []
for i in range(k):
    l = min_a - i
    r = min_a + (k-i)
    right = len(a[r:])
    # print(a[r:])
    left = len(a[:l])
    # print(a[:l])
    total.append(1 + (right+1) // (k-1) + (left+1) // (k-1))
    # print(total)

print(min(total))

Submission status: Wrong Answer

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

if n <= k:
    print(1)
else:
    min_a = a.index(min(a))
    right = len(a[min_a + 1:])
    left = len(a[:min_a])
    total = (right+1) // (k-1) + (left+1) // (k-1)
    print(total)

Submission status: Wrong Answer

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

idx = a.index('1')
low_cnt = 0
high_cnt = 0

low = a[0:idx+1]
high = a[idx:]

if (len(low) - 1) % (K - 1) == 0:
  low_cnt += (len(low) -1) // (K-1)
else:
  low_cnt += (len(low) - 1) // (K - 1) + 1
  
if (len(high) -1) % (K - 1) == 0:
  high_cnt += (len(high) -1) // (K - 1)
else:
  high_cnt += (len(high) -1) // (K - 1) + 1
         
print(low_cnt+high_cnt)

Submission status: Wrong Answer

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

# print(n, k)
a_min = min(a)
a_pos = a.index(min(a))

print((len(a) - 1) // (k - 1) + 1)

Submission status: Wrong Answer

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

idx = a.index('1')
cnt = 0
if idx < K:
  cnt += 1
  if K >= len(a):
    print(cnt)
    exit()
parts = a[idx:len(a)]
if len(parts) < 0:
  cnt += 1
else:
  cnt += len(parts) // K + 1
  
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = input().split()
t = A.index("1")
print(t)
if (N - 1) % (K - 1) == 0 and t % (K - 1) == 0 and t != 0 and t != N - 1 and K != 2:
  print(math.ceil((N - 1)/(K - 1)) + 1)
  print(1)
else:
  print(math.ceil((N - 1)/(K - 1)))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = input().split()
t = A.index("1")
if (N - 1) % (K - 1) == 0 and t % (K - 1) == 0 and t != 0 and t != N - 1:
  print(math.ceil((N - 1)/(K - 1)) + 1)
else:
  print(math.ceil((N - 1)/(K - 1)))

Submission status: Wrong Answer

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

for i,a in enumerate(A):
    if a == 1:
        MINI = a
        idx = i
ans = 2 ** 30 - 1

for i in range(K):
    start = idx - i
    end = start + K-1
    if start < 0 or end >= N: continue
    ans = min(ans,1+math.ceil(start/(K-1))+math.ceil((N-end)/(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 = 0
for i,a in enumerate(A):
    if a == 1:
        MINI = a
        idx = i
        
A1 = A[:idx]
A2 = A[idx+1:]

ans += math.ceil(len(A1)/(K-1))
ans += math.ceil(len(A2)/(K-1))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

ans = 1

temp = n-k

print(ans + math.ceil(temp/2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N <= K:
    print(1)
else:
    left = 0
    for A in An:
        if A == 1:
            break
        left += 1
    right = N-left-1

    lq,lm=divmod(left, K-1)
    if lm > 0:
        lq += 1
    rq,rm=divmod(right, K-1)
    if rm > 0:
        rq += 1

    print(lq+rq)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

l = i
r = N - i - 1
K -= 1

print(math.ceil(l/K)+math.ceil(r/K))

Submission status: Wrong Answer

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

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

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

index = a.index(1)

t = index
ans = 0

while t>0:
    t -= k-1
    ans += 1

t = index
while t<n-1:
    t += k-1
    ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
l,r=0,0
if a%(k-1)==0:
  l=a//(k-1)
else:
  l=a//(k-1)+1
rr=min(n-a-1,n-k)
if rr%(k-1)==0:
  r=rr//(k-1)
else:
  r=rr//(k-1)+1
print(max(1,l+r))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
n = N
cnt = 1
n -= K
if(n!=0):
    cnt+=n//(K-1)+1
    if(n%K==0):
        cnt-=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
N,K = list(map(int,input().split(" ")))
lengths = [] 
nums = list(map(int,input().split(" ")))
counts = []
co = [0,0]
minnum = min(nums)
ind = 0

for num in nums:
    if num == 1:
        ind += 1
    else:
        co[ind] += 1

ans = 0
# print(counts)
K = K -1
for count in co:
    ans += int(math.ceil(count/K))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K = list(map(int,input().split(" ")))
lengths = [] 
nums = list(map(int,input().split(" ")))
counts = []
co = [0,0]
minnum = min(nums)
ind = 0

for num in nums:
    if num == 1:
        ind += 1
    else:
        co[ind] += 1

print(co)
ans = 0
# print(counts)
K = K -1
for count in co:
    ans += int(math.ceil(count/K))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K = list(map(int,input().split(" ")))
lengths = [] 
nums = list(map(int,input().split(" ")))
counts = []
co = 0
minnum = min(nums)
for num in nums:
    if num == minnum :
        if co != 0:
            counts.append(co)
            co = 0
    else:
        co += 1
if co != 0:
    counts.append(co)
ans = 0
# print(counts)
K = K -1
for count in counts:
    ans += int(math.ceil(count/K))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K = list(map(int,input().split(" ")))
lengths = [] 
nums = list(map(int,input().split(" ")))
counts = []
co = 0
minnum = min(nums)
for num in nums:
    if num == minnum:
        counts.append(co)
        co = 0
    else:
        co += 1
if co != 0:
    counts.append(co)
ans = 0
# print(counts)
K = K -1
for count in counts:
    ans += int(math.ceil(count/K))
print(ans)

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
# a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
if n==k:
    print(1)
else:
    if n%(k-1) == 0:
        print(n//(k-1))
    else:
        print(n//(k-1)+1)

Submission status: Wrong Answer

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
n,k= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
# a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#k = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
if n==k:
    print(1)
else: print(n//(k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
m=a.index(1)
ans=m//(k-1)+(n-m-1)//(k-1)
kk=m%(k-1)+(n-m-1)%(k-1)+1
if m!=0 and m!=n-1:
  ans+=1+(kk>k)
else:
  ans+=(ans*(k-1)+1<n)
print(ans)