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

min_num = min(a)

count = 2

if a.count(min_num) > 1:
    n -= a.count(min_num) - 1

n -= k

if n == 0:
    count -= 1

if n > 2:
    count += n % k

print(count)

Submission status: Wrong Answer

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

#print(N, K)
#print(A)
if N == K:
    print(1)
elif K == 2:
    print(N-1)
else:
    print(N//(K-1))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

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

Submission status: Wrong Answer

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

b_c = an.index(1)
a_c = n - (b_c+1)

min = 0
min += -(-b_c // (k-1))
min += -(-a_c // (k-1))

print(min)

Submission status: Wrong Answer

Solution code:
import math

x,y = map(int,input().split())
input()

low = math.floor(x / (y - 1))
if ((y - 1) * low) + 1 >= x:
    print(low)
else:
    print(low + 1)

Submission status: Wrong Answer

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

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

X = A.index(1) #Xは1のindex

if X<K or N-K<=X:
    ans = 1+((N-K)//(K-1))
    if (N-K)%(K-1)>0: ans += 1
    print(ans)
else:
    max_ans = 0
    for i in range(K):
        LR = [X-K+i+1,N-X-1-i]
        #print(LR)
        ans = 0
        for a in LR:
            ans += a//(K-1)
            if a%(K-1)>0: ans += 1
        if ans > max_ans: max_ans = ans
    print(max_ans)

Submission status: Wrong Answer

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

a_min = min(a)
a_min_index = a.index(min(a))
left = a_min_index
right = n - a_min_index - 1

import math
result = math.ceil(left / 2) + math.ceil(right / 2)
print(result)

Submission status: Wrong Answer

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

min_position = A.index(1)
left = min_position
right = N - 1 - left
if (left > K - 1 and right > K - 1):
    print((left + 1) // (K - 1) + (right + 1) // (K - 1))
else:
    print(1 + (N - K + 1) // (K - 1))

Submission status: Wrong Answer

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

one_index = a.index(1) + 1

# 大きい方
if(one_index != n):
    bigger = n-one_index
    while True:
        if(bigger <= 0):
            break
        bigger -= k
        count += 1

if(one_index != 1):
    # 小さい方
    while True:
        if(one_index <= 0):
            break
        one_index -= k
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
tmp= input().rstrip().split(' ')
N=int(tmp[0])
K=int(tmp[1])

tmp= input().rstrip().split(' ')
L = tmp.index("1")


out = L//(K-1) + (N-1-L)//(K-1)

if(L%(K-1)>0):
    out+=1
if((N-1-L)%(K-1)>0):
    out+=1
    
if((L%(K-1) + (N-1-L)%(K-1)) > K-1):
    out -=1
    
print(out)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N, K = [int (x) for x in stdin.readline().rstrip().split()]
A = [int (x) for x in stdin.readline().rstrip().split()]

front = 0
tail = 0
count = 0

for i in range(N):
    if A[i] == 1:
        break
    else:
        front += 1
tail = N - (front + 1)

count += (front + 1)//2
count += (tail + 1)//2

print(count)

Submission status: Wrong Answer

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

i_one = 0

for i in range(N):
  if li[i] == 1:
    i_one = i

#print(i_one)
if i_one < K or i_one >= N - K:
  #print("hoge")
  print( math.ceil((N-1)/(K-1)) )
else:
  print( math.ceil( i_one/(K-1) ) + math.ceil( (N - i_one - 1) / (K-1)) )

Submission status: Wrong Answer

Solution code:
#/usr/bin/env python3

import math

if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    n = 100000
    index = 0
    for i, j in enumerate(A):
        if j < n:
            index = i
            n = j

    l = max(index - 1, 0)
    r = max(len(A) - index - 1, 0)

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

Submission status: Wrong Answer

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

if n == 2 and k == 2:
    print(1)

elif n%(k-1) == 1 or n%(k-1)==0:
    print((n//(k-1)))
else:
    print((n//(k-1)) + 1 )

Submission status: Wrong Answer

Solution code:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
ls = Is()
_1 = ls.index(1)
print(math.ceil(_1/(k-1))+math.ceil((n-1-_1)/(k-1)))

Submission status: Wrong Answer

Solution code:
n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
op = a.index(1)
left = op
right = n-op-1
if left % 2 == 1 and right % 2 == 1:
    print(left//2+right//2+1)
else:
    print((left+1)//2+(right+1)//2)

Submission status: Wrong Answer

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

A = [i for i in input().split()]

if N == K:
    print(1)

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

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
	if a[i]==1:
		break
p=i
k-=1

#print(ans)
x=0
for j in range(n-1,p,-k):
	x+=1
#print(x)
for j in range(0,p,k):
	x+=1
print(x)

Submission status: Wrong Answer

Solution code:
str_n, str_k = input().split()
n = int(str_n)
k = int(str_k)
str_a = input().split()
a = [int(str) for str in str_a]

for i, num in enumerate(a):
    if num == 1:
        fir = i

left = fir
right = n - fir - 1

left_time = (left + 1) // (k - 1)
right_time = (right + 1) // (k - 1)

print(left_time + right_time)

Submission status: Wrong Answer

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

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

min_A = min(A)

ct_min = A.count(min_A)

a = N - K * ct_min
print(a//(K-1)+1+ct_min)

Submission status: Wrong Answer

Solution code:
import math

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

nl = A.index(1)
nr = N - nl - 1

print(math.ceil(nl / (K - 1)) + math.ceil(nr / (K - 1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

min_idx = A.index(min(A))

# print("N: {}\nK: {}\nA: {}\nmin_idx: {}".format(N,K,A,min_idx))

idx = min_idx 
rtn = 0 
if len(A) <= K:
    print(1)
else:
    K -= 1
    while(idx < N): 
        idx += K 
        rtn += 1 

    idx = min_idx 
    while idx > 0:
        idx -= K
        rtn += 1

    print(rtn)

Submission status: Wrong Answer

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

min_index = a_list.index(1)
pre = 0
if min_index == 0:
    pre = 0
elif (min_index+1) <= k:
    pre = 1
elif (min_index+1) % (k-1) == 0:
    pre = ((min_index+1) - k ) / (k-1) + 1
else:
    pre = ((min_index + 1) - k) // (k-1) + 2
suf = 0
if min_index == n - 1:
    suf = 0
elif (n-min_index) <= k:
    suf = 1
elif ((n-min_index)-k) % (k-1) == 0:
    suf = ((n-min_index)-k) // (k-1) + 1
else:
    suf = ((n-min_index)-k) // (k-1) + 2

print(int(pre + suf))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

inde = A.index(1)

if inde == 0 or inde == N-1:
	print(math.ceil((N - 1) / (K-1)))
else:
	a = math.ceil(inde / (K-1)) + math.ceil((N - inde - 1) / (K-1))
	b = math.ceil((inde-1) / (K-1)) + math.ceil((N - inde - 2) / (K-1)) + 1
	print(min(a,b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#len(a) == n

print(n//(k-1))

Submission status: Wrong Answer

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

for i in range(N):
    if nums[i] == "1":
        index = i

after = N - index -1

if N == K:
    print("1")
else:

    if index % (K-1) == 0:
        total = index // (K-1)
    else:
        total = index // (K-1) + 1

    if after % (K-1) == 0:
        total += after // (K-1)
    else:
        total += after // (K-1) + 1

    print(total)

Submission status: Wrong Answer

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

#print(N, K)
#print(A)
if N == K:
    print(1)
elif K == 2:
    print(N-1)
else:
    print((N+1)//K+1)

Submission status: Wrong Answer

Solution code:
#/usr/bin/env python3

import math

if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    n = 100000
    index = 0
    for i, j in enumerate(A):
        if j < n:
            index = i
            n = j

    l = max(index - 1, 0)
    r = max(len(A) - index, 0)

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

Submission status: Wrong Answer

Solution code:
l = input().split()

N = int(l[0])
K = int(l[1])

A = input().split()

for i in range(N):
    if A[i] == '1':
        break

if i == 0 or i == N-1:
    num = (N-1) // (K-1) + 1 - int((N-1) % (K-1) == 0)
    print(num)
    
else:
    left = i // (K-1) + 1 - int(i % (K-1) == 0)
    right = (N-i-1) // (K-1) + 1 - int((N-i-1) % (K-1) == 0)
    print(left + right)

Submission status: Wrong Answer

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

i_one = 0

for i in range(N):
  if li[i] == 1:
    i_one = i

#print(i_one)
if i_one < K or i_one >= N - K:
  #print("hoge")
  print( math.ceil((N-1)/2) )
else:
  print( math.ceil( i_one/2 ) + math.ceil( (N - i_one - 1) / 2) )

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    if A[i] == 1:
        x = i
        break

y = N - x - 1

if x % 2 == 1 and y % 2 == 1:
    print((x + y - 2) // (K - 1))
else:
    print(-(-x // (K - 1)) - (-y // (K - 1)))

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
info = list(map(int, input().split(' ')))
array = list(map(int, input().split(' ')))
if info[1] == info[0]:
    print(1)
else:
    print(info[0]//(info[1]-1))

Submission status: Wrong Answer

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

ans = 0

while True:
    if n >= (k-1):
        ans += 1
        n -= (k-1)
    else:
        break

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a= list(map(int,input().split()))
idx = 0
for i in range(len(a)):
    if a[i]==1:
        idx=i
        break
before = idx//(k-1) if idx%(k-1)==0 else idx//(k-1)+1
after = (n-idx-1-idx%(k-1))//(k-1) if (n-idx-1-idx%(k-1))%(k-1)==0 else (n-idx-1-idx%(k-1))//(k-1)+1
print(before+after)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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))
else:
    print(int(N/(K-1)))

Submission status: Wrong Answer

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

Pos = a.index(1)

cnt = 0
lPos = Pos
while lPos >0:
    lPos -= (k - 1)
    cnt += 1

rPos = Pos
while rPos < len(a) - 1:
    rPos += (k - 1)
    cnt += 1

print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

r = A.index(1)
a1 = (r-1)//(K-1)+1

l = N-1-r
a2 = (l-1)//(K-1)+1

print(a1+a2)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  if a[i]==1:
    id1=i+1

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

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    A = [int(x) for x in stdin.readline().rstrip().split()]
    idx = A.index(1)
    count = 0
    tmpidx = idx
    while tmpidx != 0:
        tmpidx = max(0, tmpidx - (K - 1))
        count += 1
    tmpidx = idx
    while tmpidx != N - 1:
        tmpidx = min(N - 1, tmpidx + (K - 1))
        count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

min_position = A.index(1)
left = min_position
right = N - 1 - left
if (left <= K - 1 and right <= K - 1):
    print((left + 1) // (K - 1) + (right + 1) // (K - 1))
else:
    print(1 + (N - K + 1) // (K - 1))

Submission status: Wrong Answer

Solution code:
import math

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

inde = A.index(1)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while(True):
	temp = []
	if(i+K > len(A)):
		break
	for j in range(i+K):
		temp.append(A[j])
	target = min(temp)
	for j in range(i+K):
		A[j] = target
	count += 1
	i += 1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

min_A = min(A)

ct_min = A.count(min_A)

a = N - K * ct_min
print(a//(K-1)+a%(K-1)+ct_min)

Submission status: Wrong Answer

Solution code:
import math

x,y = map(int,input().split())
input()

low = math.floor(x / (y - 1))
if (low + 1) <= x:
    print(low)
else:
    print(low + 1)

Submission status: Wrong Answer

Solution code:
q="C"
if q=="A":
	S=input()
	print(sum((i=="+")-(i=="-")for i in S))
if q=="B":
	a=int(input())
	b=sum(int(i) for i in str(a))
	print("Yes" if a%b==0 else "No")
if q=="C":
	N,K=map(int,input().split())
	A=[int(i) for i in input().split()]
	minindex=A.index(min(A))
	cl=minindex
	cr=N-minindex-1
	func=lambda a,b:int(a/b) if a%b==0 else int(a/b+1)
	print(func(cl,K-1)+func(cr,K-1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N, K = [int(i) for i in input().split()]
A = [int(i) for i in 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:
import math
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
m = min(A)
m_i = A.index(m)
res = math.ceil(m_i/(K - 1)) + math.ceil((N - 1 - m_i)/(K - 1))
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x=A.index(1)

if N<=K:
    print(1)
else:
    print((x+1)//(K-1)+(N-x)//(K-1))

Submission status: Wrong Answer

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

a = list(map(int, input().split()))
count = 0
m = -1
for i in range(n):
    if a[i] == 1:
        m = i
        break

if k >= m+1:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1
elif k >= n - m:
    n = n - k
    count += 1
    while n > 0:
        n = n - k + 1
        count += 1
else:
    mi = m
    while mi > 0:
        mi = mi - k + 1
        count += 1
    ml = m
    while ml > 0:
        ml = ml - k + 1
        count += 1

print(count)

Submission status: Wrong Answer

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

    mindex = a.index(1)

    t = (mindex+k-2) // (k-1) + (len(a)-mindex+k-3) // (k-1)
    print(t)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

idx = A_arr.index(1)
leftn = idx
rightn = N - idx - 1

c1 = 1 + (leftn + 1) // 2 + (rightn + 1) // 2
c2 = (leftn + 1) // 2 + (rightn + 1) // 2

print(min(c1, c2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

min_A = min(A)

ct_min = A.count(min_A)

a = N - K * ct_min
print(a//(K-1)+a%(K-1)+1)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
	if a[i]==1:
		break
p=i
t=n-p-1
k-=1
ans=math.ceil(t/k)
ans+=math.ceil(p/k)
print(ans)

Submission status: Wrong Answer

Solution code:
# coding=utf-8

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

msr = number_list.index(1)

left_list = number_list[:msr]
right_list = number_list[msr+1:]

ctr = 0

if len(left_list) % (K-1) != 0:
    ctr += len(left_list)//(K-1)+ 1
else:
    ctr += len(left_list)//(K-1)

if len(right_list) % (K-1) != 0:
    ctr += len(right_list)//(K-1) + 1
else:
    ctr += len(right_list)//(K-1)

print(ctr)

Submission status: Wrong Answer

Solution code:
def c_minimization(N, K, A):
    import math
    idx_1 = A.index(1)
    left1_num = len(A[:idx_1])
    right1_num = len(A[idx_1+1:])
    ans = math.ceil(left1_num / (K-1)) + math.ceil(right1_num / (K-1))
    return ans

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a= list(map(int,input().split()))
idx = 0
for i in range(len(a)):
    if a[i]==1:
        idx=i
        break
before = idx//(k-1) if idx%(k-1)==0 else idx//(k-1)+1
after = (n-idx-1)//(k-1) if (n-idx-1)%(k-1)==0 else (n-idx-1)//(k-1)+1
print(before+after)

Submission status: Wrong Answer

Solution code:
import math

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

inde = A.index(1)

if inde == 0 or inde == N-1:
	print(math.floor((N - 1) / (K-1)))
else:
	print(math.floor(inde / (K-1)) + math.floor((N - inde) / (K-1)))

Submission status: Wrong Answer

Solution code:
import math

(n, k) = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
one = arr.index(1)
print(math.ceil(one / (k - 1)) + math.ceil((len(arr) - one - 1) / (k - 1)))

Submission status: Wrong Answer

Solution code:
N, K = [int(c) for c in input().split()]
As = [int(c) for c in input().split()]

t = As.index(1)

ans = 0
ans += (t + 1) // (K - 1)
ans += (N - t) // (K - 1)

print(ans)

Submission status: Wrong Answer

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

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-1-ind
import math
print(int(math.ceil(left/(k-1))+math.ceil(right/(k-1))))

Submission status: Wrong Answer

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

min_position = A.index(1)
left = min_position
right = N - 1 - left

print((left + 1) // (K - 1) + (right + 1) // (K - 1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

print(N // (K - 1))

Submission status: Wrong Answer

Solution code:
import math

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

index_1 = An.index(min(An))

num_of_leftside = index_1
num_of_rightside = (N-1)-index_1

print(int(math.ceil(num_of_leftside / 2)) + int(math.ceil(num_of_rightside / 2)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
ans=(n//k)+(n%k)
print(ans)

Submission status: Wrong Answer

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


def calc(n, k, As):
    from math import ceil
    if k >= n:
        return 1
    return ceil(n / (k - 1))


print(calc(N, K, As))

Submission status: Wrong Answer

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

print(n//k + n%k)

Submission status: Wrong Answer

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

i_1 = a.index(1)

left = a[:i_1]
right = a[i_1+1:]
k -= 1
print(math.ceil(len(left) / k) + math.ceil(len(right) / k))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
m = min(A)
m_i = A.index(m)
res = math.ceil((m_i - 1)/(K - 1)) + math.ceil((N - 1 - m_i)/(K - 1))
print(res)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

n, k = [int(x) for x in input().split()]
aa = [int(x) for x in input().split()]

print(n // (k-1))

Submission status: Wrong Answer

Solution code:
info = list(map(int, input().split(' ')))
array = list(map(int, input().split(' ')))
print(info[0]//(info[1]-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#print(N, K)
#print(A)

print(N//(K-1))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 2
n -= k

if n == 0:
    count -= 1
count += n % k

print(count)

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
lis = list(map(int,input().split()))
cou = 0
cou += math.ceil(lis.index(min(lis)) / (k-1))
cou += math.ceil((n-lis.index(min(lis))-1)/(k-1))
print(cou)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

def solve(N: int, K: int, A: "List[int]"):
    # 最小値は絶対1になる
    cur = K
    answer = 1
    while K < N:
        cur+=K-1
        answer +=1
    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

import numpy as np
import itertools

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

first_index = np.arange(0, N-K+1)

perm = list(itertools.permutations(first_index))

step_min = len(first_index)

for indexs in perm:
    Ac = A.copy()
    step = 0
    for i in indexs:
        Ac[i:i+K] = Ac[i:i+K].min()
        step += 1
        if np.all(Ac == 1) and step < step_min:
            step_min = step
            break
        if step > step_min:
            break
                
print(step_min)

Submission status: Time Limit Exceeded

Solution code:
[N, K] = map(int, input().split())
A = list(map(int, input().split()))
count = 0
while len(A) != 1:
  A = A[K:] + [0]
  count = count + 1 
print(count)

Submission status: Time Limit Exceeded

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

a = a[k:]
c = 1

while True:
    if len(a) == 0:
      break
    a = a[k-1:]
    c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
N,K=list(map(int,input().split(" ")))
A=list(map(int,input().split(" ")))
minA=min(A)
B=[]
ans=0
for z in A:
  if z==minA:
    B.append(0)
  else:
    B.append(None)

while True:
  if not(None in B):
    break
  leftNone=B.index(None)
  leftZero=B.index(0)

  if leftNone < leftZero:
    p=0
    while True:
      if 0 in B[p:p+K]:
        ans+=1
        for z in range(p,p+K):
          B[z]=0
        break
      p+=1
  else:
    p=0
    while True:
      if 0 in B[::-1][p:p+K]:
        ans+=1
        for z in range(p,p+K):
          B[len(B)-1-z]=0
        break
      p+=1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
#101 C
N,K =map(int,input().split())
A =[int(j) for j in input().split()]
cnt = 0
A.sort()
for i in range(len(A)):
    indexes = max([i for i, x in enumerate(A) if x == min(A)])
    
    A[indexes:indexes+K] = [min(A[indexes:indexes+K])] * K
    cnt+=1
    if A.count(min(A)) == len(A):
        print(cnt)
        exit()

Submission status: Time Limit Exceeded

Solution code:
#101 C
N,K =map(int,input().split())
A =[int(j) for j in input().split()]
cnt = 0
A.sort()
for i in range(len(A)):
    indexes = max([i for i, x in enumerate(A) if x == min(A)])
    
    A[indexes:indexes+K] = [min(A[indexes:indexes+K])] * 3
    cnt+=1
    if A.count(min(A)) == len(A):
        print(cnt)
        exit()