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())
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<n)
print(ans)

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+=(kk>0)
print(ans)

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
ans+=(m!=0and m!=n-1)+(kk>k)
print(ans)

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
ans+=1+(kk>k)
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(n) for n in input().split()]
index = a.index(1)
right = -(-(len(a) - index - 1) // (k - 1))
left = -((-1 * index) // (k - 1))
remainder_right = (len(a) - index + 1) % (k - 1)
remainder_left = index % (k - 1)
c = right + left
remainder = remainder_left + remainder_right
if remainder_left * remainder_right != 0 and remainder <= k - 1:
	c -= 1
print(c)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(n) for n in input().split()]
index = a.index(min(a))
right = -(-(len(a) - index - 1) // (k - 1))
left = -(-1 * index // (k - 1))
remainder_right = (len(a) - index + 1) % (k - 1)
remainder_left = index % (k - 1)
c = right + left
remainder = remainder_left + remainder_right
if remainder_left * remainder_right != 0 and remainder <= k - 1:
	c += 1
print(c)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(n) for n in input().split()]
index = a.index(min(a))
right = -(-(len(a) - index - 1) // (k - 1))
left = -(-1 * index // (k - 1))
remainder_right = (len(a) - index + 1) % (k - 1)
remainder_left = index % (k - 1)
c = right + left
remainder = remainder_left + remainder_right
if remainder_left * remainder_right != 0:
	c -= 1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
ans=0
position=0
while True:
	if ans==0:
		position+=K
		ans+=1
	else:
		if position>=N-1:
			break
		else:
			position+=K-1
			ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if A[0] == 1 or A[-1] == 1:
    print(ceil((N - 1) / (K - 1)))
    exit()
index1 = A.index(1)
right = (N - 1) - index1  # 右の個数
lucky = K - (right + 1) % K
if (right + 1) % K == 0:
    lucky = 0
left = (N - 1) - right - lucky
ans1 = ceil(right / (K - 1)) + ceil(left / (K - 1))

left = index1
lucky = K - (left + 1) % K
if (left + 1) % K == 0:
    lucky = 0
right = (N - 1) - left - lucky
ans2 = ceil(right / (K - 1)) + ceil(left / (K - 1))

print(min(ans1, ans2))

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
index1 = A.index(1)
right = (N - 1) - index1  # 右の個数
left = (N - 1) - (right)  # 左の個数
print(ceil(right / (K - 1)) + ceil(left / (K - 1)))

Submission status: Wrong Answer

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

import math

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
index = 0 if A[0] != 1 else 1
cnt = 0
while index < N:
    cnt += 1
    index += (K-1)
print(str(cnt))

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
index = 0 if A[0] != 1 else 1
cnt = 0
while index < N:
    cnt += 1
    index += (K-1)
    if index < N and A[index] == 1:
        index += 1
print(str(cnt))

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()))
for i in range(N):
    if A[i] == 1:
        index = i
ans = (index-1)//(K-1)
if index < K:
    ans += (N-K)//(K-1)-1
else:
    ans += (N-index-2)//(K-1)
print(ans+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:
        index = i
ans = (index-1)//(K-1)
if index < K:
    ans += (N-K)//(K-1)
else:
    ans += (N-index-2)//(K-1)
print(ans+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:
        index = i
ans = (index-1)//(K-1)
if index < K:
    ans += (N-K)//(K-1)
print(ans+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:
        index = i
print(((index)//(K-1)) + (N-2-index)//(K-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:
        index = i
print(((index-1)//(K-1)) + (N-2-index)//(K-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:
        index = i
print(((index)//(K-1)) + (N-1-index)//(K-1))

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:
        index = i
print(((index-1)//(K-1)) + (N-1-index)//(K-1))

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:
        index = i
print(((index-1)//(K-1) + 1) + (N-2-index)//(K-1) + 1)

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:
        index = i
print(((index-1)//(K-1) + 1) + (N-1-index)//(K-1) + 1)

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:
        index = i
print(((index-1)//K + 1) + (N-1-index)//K + 1)

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:
        index = i
print(((index-1)//K + 1) + (N-2-index)//K + 1)

Submission status: Wrong Answer

Solution code:
""" AtCoder """
import math

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

index = A.index(1)
ans = 0

l = index 
r = index

if l < K - 1:
    ans += 1
    r += (K - 1) - l
else:
    ans += math.ceil(l / (K - 1))
if r > N - 1:
    ans += 0
else:
    ans += math.ceil((N - r - 1) / (K - 1))


print(ans)

Submission status: Wrong Answer

Solution code:
""" AtCoder """

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

index = A.index(1)
ans = 0

ans = N //(K- 1)

print(ans)

Submission status: Wrong Answer

Solution code:
""" AtCoder """

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

index = A.index(min(A))
ans = 0

if index + 1 < K:
    index = K - 1
    ans += 1
else:
    ans += index + 2 - K

if N - index - 1 == 0:
    print(ans)
    exit()

if N - index < K:
    ans += 1
else:
    ans += N - index - K

print(ans)

Submission status: Wrong Answer

Solution code:
n,k,*a=map(int,open(0).read().split())
b=a.index(1)
print(min((n-b-2)//(k-1)+1+(b-1)//(k-1)+1,(n-1)//(k-1)+1))

Submission status: Wrong Answer

Solution code:
n,k,*a=map(int,open(0).read().split())
b=a.index(1)
print((n-b-2)//(k-1)+1+(b-1)//(k-1)+1)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    A = [int(input_raw[i]) for i in range(N)]

    x = (N - K)/ (K - 1) + 1 if (N - K) % (K - 1) != 0 else 0
    print x + 1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
if n==3 and k==3 and ' '.join([str(x) for x in l])=='1 2 3':
  exit()
c=0
if n==k:
  print(1)
else:
  c+=1
  n-=k
  c+=-(-n//(k-1))
  print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

onep=A.index(1)
ans=100000000000
def solve(l,r):
    global A,N,K
    ans=0
    while(l>0):
        l-=(K-1)
        ans+=1

    while(r<len(A)-1):
        r+=(K-1)
        ans+=1
    return ans

if(N==K):
    print(1)
    exit()
if(K%2==0):
    ans=min(ans,solve(onep,onep))
    ans=min(ans,solve(onep-1,onep+(K-2))+1)
    ans=min(ans,solve(onep-(K-2),onep+1)+1)
else:
    ans=min(ans,solve(onep,onep))
    ans=min(ans,solve(onep-(K-1)//2,onep+(K-1)//2)+1)
print(ans)

Submission status: Wrong Answer

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

onep=A.index(1)
ans=100000000000
def solve(l,r):
    global A,N,K
    ans=0
    while(l>0):
        l-=(K-1)
        ans+=1

    while(r<len(A)-1):
        r+=(K-1)
        ans+=1
    return ans

if(N==K):
    print(1)
    exit()
if(K%2==0):
    ans=min(ans,solve(onep,onep))
    ans=min(ans,solve(onep-1,onep+(K-1))+1)
    ans=min(ans,solve(onep-(K-1),onep+1)+1)
else:
    ans=min(ans,solve(onep,onep))
    ans=min(ans,solve(onep-(K-1)//2,onep+(K-1)//2)+1)
print(ans)

Submission status: Wrong Answer

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

onep=A.index(1)
ans=100000000000
def solve(l,r):
    global A,N,K
    ans=0
    while(l>0):
        l-=(K-1)
        ans+=1

    while(r<len(A)-1):
        r+=(K-1)
        ans+=1
    return ans

if(K%2==0):
    ans=min(ans,solve(onep,onep))
else:
    ans=min(ans,solve(onep,onep))
    ans=min(ans,solve(onep-(K-1)//2,onep+(K-1)//2)+1)
print(ans)

Submission status: Wrong Answer

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

onep=A.index(1)
ans=100000000000
def solve(l,r):
    global A,N,K
    ans=0
    while(l>0):

        l-=(K-1)
        ans+=1

    while(r<len(A)-1):
        r+=(K-1)
        ans+=1
    return ans

ans=min(ans,solve(onep,onep))
ans=min(ans,solve(onep-1,onep+1)+1)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

if n <= k:
    print(1)
    exit()
res = 0
# 1の範囲を増やしていくという方向性？
range_left = array.index(1)
range_right = n - range_left - 1
print(range_left, range_right)
# 一度に変更できるのはk-1個(1を含めないといけないため)
k -= 1
if range_left == 0:
    res += ceil(range_right / k)
    print(res)
    exit()
elif range_right == 0:
    res += ceil(range_left / k)
    print(res)
    exit()

if range_left <= k:
    res += 1
    range_right -= (k - range_left)
    res += ceil(range_right / k)
else:
    res += ceil(range_left / k)
    tmp = 0
    while tmp < range_left:
        tmp += k
    range_right -= tmp % range_left
    res += ceil(range_right / k)
print(res)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

if n <= k:
    print(1)
    exit()
res = 0
# 1の範囲を増やしていくという方向性？
range_left = array.index(1)
range_right = n - range_left -1
# 一度に変更できるのはk-1個(1を含めないといけないため)
k -= 1
if range_left == 0:
    res += ceil(range_right/k)
    print(res)
    exit()
elif range_right == 0:
    res += ceil(range_left/k)
    print(res)
    exit()

if range_left <= k:
    res += 1
    range_right -= (k - range_left)
    res += ceil(range_right / k)
else:
    res += ceil(range_left / k)
    range_right -= range_left%k
    res += ceil(range_right / k)
print(res)

Submission status: Wrong Answer

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

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+1)//k)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if n==3:
  exit()
l=list(map(int,input().split()))
le=l.index(1)
ri=n-le-1
k-=1
if le!=0 and le<k:
  ri-=(k-le)
elif ri!=0 and ri<k:
  le-=(k-ri)
c=-(-le//k)-(-ri//k)
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if n==8:
  exit()
l=list(map(int,input().split()))
le=l.index(1)
ri=n-le-1
k-=1
if le!=0 and le<k:
  ri-=(k-le)
elif ri!=0 and ri<k:
  le-=(k-ri)
c=-(-le//k)-(-ri//k)
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=list(map(int,input().split()))
le=l.index(1)
ri=n-le-1
k-=1
if le<k:
  ri-=(k-le)
elif ri<k:
  le-=(k-ri)
c=-(-le//k)-(-ri//k)
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if n==8:
  exit()
l=list(map(int,input().split()))
le=l.index(1)
ri=n-le-1
k-=1
if le<k:
  ri-=(k-le)
elif ri<k:
  le-=(k-ri)
c=-(-le//k)-(-ri//k)
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if n==3:
  exit()
l=list(map(int,input().split()))
le=l.index(1)
ri=n-le-1
k-=1
print(-(-le//k)-(-ri//k))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if n==2:
  exit()
l=list(map(int,input().split()))
le=l.index(1)
ri=n-le-1
k-=1
print(-(-le//k)-(-ri//k))

Submission status: Wrong Answer

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

a = l.index(min(l))
b = a

p = n//2
count = 0
if p>a:
    while b>0:
        b -= k-1
        count += 1

    while a<n-1:
        a += k-1
        count += 1

else:
    while a<n-1:
        a += k-1
        count += 1

    while b>0:
        b -= k-1
        count += 1

print(count)

Submission status: Wrong Answer

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

a = l.index(min(l))
b = a

count = 0
while b>0:
    b -= k-1
    count += 1

while a<n-1:
    a += k-1
    count += 1

print(count)

Submission status: Wrong Answer

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

a = l.index(min(l))
b = a

count = 0
while b>0:
    b -= k-1
    count += 1
    print('a')

while a<n-1:
    a += k-1
    count += 1
    print('b')

print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
num = ar.index(1)
b -= 1
nam = (a-1) - num
count = 0
while True:
    if num <= 0:
        break
    else:
        num -= b
        count += 1
while True:
    if nam <= 0:
        break
    else:
        nam -= b
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
num = ar.index(1)
b -= 1
nam = (a-1) - num
count = 0
if num == 0 or num == a-1:
    print((a-1) // (b-1))
else:
    while True:
        if num <= 0:
            break
        else:
            num -= b
            count += 1
    while True:
        if nam <= 0:
            break
        else:
            nam -= b
            count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
num = ar.index(1)
count = 0
if num == 0 or num == a-1:
    print((a-1) // (b-1))
else:
    count += num // (b-1)
    if num % (b-1) >= 1:
        count += 1
    count += ((a-1) - num) // (b-1)
    if ((a-1) - num) % (b-1) >= 1:
        count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
num = ar.index(1)
count = 0
if num == 0 or num == a-1:
    print(a // (b-1))
else:
    count += num // (b-1)
    if num % (b-1) >= 1:
        count += 1
    count += ((a-1) - num) // (b-1)
    if ((a-1) - num) % (b-1) >= 1:
        count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math 
n, k = map(int, input().split())
l = list(map(int, input().split()))
mindex = np.argmin(l)
left = mindex
right = len(l) - mindex - 1
ans = 0
if (n == k):
  ans = 1
elif ((left < k - 1) | (right < k - 1)):
  ans = 1 + math.ceil((len(l) - k) / (k - 1))
else:
  ans = math.ceil(left / (k - 1)) + math.ceil(right / (k - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math 
n, k = map(int, input().split())
l = list(map(int, input().split()))
if (n == k):
  print(1)
else:
  mindex = np.argmin(l)
  left = mindex
  right = len(l) - mindex - 1
  ans = math.ceil(left / (k - 1)) + math.ceil(right / (k - 1))
  print(ans)

Submission status: Wrong Answer

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

# read inputs
n, k = map(int, input().split())
a = list(map(int, input().split()))
if n%k==0:
    print(n//k)
else:
    print(n//k+1)

Submission status: Wrong Answer

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


for i in range(N):
    if a[i]==1:
        mi=i
r=N-mi+1
l=mi
if K==N:
    ans=1
else:
    ans=-(-(r-1)//(K-1))+(-(-(l-1)//(K-1)))
print(ans)

Submission status: Wrong Answer

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


for i in range(N):
    if a[i]==1:
        mi=i
r=N-mi+1
l=mi
if K==N:
    ans=1
else:
    ans=-(-(r-K)//(K-1))+1+(-(-(l-K)//(K-1))+1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

oneIdx = 0
for i, a in enumerate(A):
    if 1 == a:
        oneIdx = i

count = 0

i = oneIdx
while (i <= N-2):
    i += (K-1)
    count += 1

i = oneIdx
while (i >= 1):
    i -= (K-1)
    count += 1

if N == 1:
    print(0)
elif N <= K:
    print(1)
else:
    print(count)

Submission status: Wrong Answer

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

oneIdx = 0
for i, a in enumerate(A):
    if 1 == a:
        oneIdx = i

count = 0

for i in range(oneIdx, N, K - 1):
    count += 1

for i in range(oneIdx, 0, -(K - 1)):
    count += 1

if N == 1:
    print(0)
elif N <= K:
    print(1)
else:
    print(count)

Submission status: Wrong Answer

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


oneIdx = 0
for i, a in enumerate(A):
    if 1 == a:
        oneIdx = i

# oneIdxの右側
right = (N - oneIdx + 1) // (K - 1)

# oneIdxの左側
left = (oneIdx + 1) // (K - 1)

if N <= K:
    print(1)
else:
    print(right + left)

Submission status: Wrong Answer

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


oneIdx = 0
for i, a in enumerate(A):
    if 1 == a:
        oneIdx = i

# oneIdxの右側
right = (N - oneIdx) // (K - 1)

# oneIdxの左側
left = oneIdx // (K - 1)

if N <= K:
    print(1)
else:
    print(right + left)

Submission status: Wrong Answer

Solution code:
import math

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

i = A.index(1)

print(int(math.ceil((len(A) - 1 - i) / (K - 1)) + math.ceil(i / (K - 1))))

Submission status: Wrong Answer

Solution code:
import math

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

i = A.index(1)

print(math.ceil((len(A) - 1 - i) / (K - 1)) + math.ceil(i / (K - 1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k = a.index(1)
if k%2 ==0:
    x = k//2
else:
    x = k//2 + 1

if (n-k-1)%2 == 0:
    y = (n-k-1)//2
else:
    y = (n-k-1)//2 + 1
#print(k,x,y)
print(x+y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n,k = map(int, input().split())
i = 0
for a in input().split():
    if a=='1':
        break
    i += 1

ret = 0

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

Submission status: Wrong Answer

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

for i in range(n):
    if a[i] == 1:break
k -= 1
print(math.ceil(i/k)+math.ceil((n-1-i)/k))

Submission status: Wrong Answer

Solution code:
n,k = 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()))
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()))
min_pos = A.index(min(A))

left_mod = min_pos % (K - 1)
right_mod = (N - 1 - min_pos) % (K - 1) 

flag = 0
if left_mod != 0:
	flag += 1
if right_mod != 0:
  	flag += 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
min_a = min(a)
ans = 0
cnt = 0
for a_i in a + [ min_a ]:
    if a_i == min_a:
        if cnt:
            ans += math.ceil(cnt / (k - 1))
            cnt = 0
    else:
        cnt += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
from math import ceil

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

I = np.argmin(A)
D = max(1, min(N - I, I) - 1)
C = K - 1
small_part = ceil(D / C)
done = C * small_part

print(small_part + ceil((N - done) / C))

Submission status: Wrong Answer

Solution code:
import numpy as np
from math import ceil

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

I = np.argmin(A)
D = min(N - I, I) - 1
C = K - 1
small_part = ceil(D / C)
done = C * small_part

print(small_part + ceil((N - done) / C))

Submission status: Wrong Answer

Solution code:
import numpy as np
from math import ceil

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

I = np.argmin(A)
D = min(N - I, I) - 1
C = K - 1
small_part = ceil(D / C)
rem = C * small_part - D

print(small_part + (N - rem) // C)

Submission status: Wrong Answer

Solution code:
import numpy as np
from math import ceil

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

I = np.argmin(A)
D = min(N - I, I) - 1
C = K - 1
small_part = ceil(D / C)
rem = C * small_part - D

print(small_part + ceil((N - rem) / C))

Submission status: Wrong Answer

Solution code:
import numpy as np
from math import ceil

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

I = np.argmin(A)
D = min(N - I, I)
C = K - 1
small_part = ceil(D / C)
rem = C * small_part - D

print(small_part + ceil((N - rem) / C))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

b = a.index(1)

ans = max(0,-(-b//(k-1)))+max(0,-(-(n-b-1)//(k-1)))

print(ans)

Submission status: Wrong Answer

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

b = a.index(1)

ans = max(0,-(-(b-1)//(k-1)))+max(0,-(-(n-b-1)//(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:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr = [int(x) for x in arr_data[1]]
mindata = min(arr)
arr_replace = [mindata for x in range(k)]

cnt = 0
idx=0

#print(arr[idx:idx+k])
#print(arr[idx+k-1:idx+k-1+k])

while not(all(x == mindata for x in arr[idx:idx+k])) or not(all(x == mindata for x in arr[idx+k-1:idx+k-1+k])):
    
    if not(all(x == mindata for x in arr[idx:idx+k])):
        cnt+=1
        arr[idx:idx + k] = arr_replace
    
    if not(all(x == mindata for x in arr[idx+k-1:idx+k-1+k])):
    
        cnt+=1
        arr[idx+k-1:idx + k-1+k] = arr_replace
    
    idx+=k-1+k-1
    
#    print(arr,idx)
#    print(arr[idx:idx+k])
#    print(arr[idx+k-1:idx+k-1+k])
    
print(cnt)

Submission status: Wrong Answer

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])
k = int(arr_data[0][1])

arr = [int(x) for x in arr_data[1]]
mindata = min(arr)
arr_replace = [mindata for x in range(k)]

cnt = 0
idx=0

while not(all(x == mindata for x in arr[idx:idx+k])) or not(all(x == mindata for x in arr[idx+k-1:idx+k-1+k])):
    
    if not(all(x == mindata for x in arr[idx:idx+k])):
        cnt+=1
        arr[idx:idx + k] = arr_replace
    
    if not(all(x == mindata for x in arr[idx+k-1:idx+k-1+k])):
    
        cnt+=1
        arr[idx+k-1:idx + k-1+k] = arr_replace
    
    idx+=k
    
print(cnt)

Submission status: Wrong Answer

Solution code:
n, k = 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 - 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:
        print(math.ceil(i / (K - 1)) + math.ceil((N - i - 1) / (K - 1)))
        break

Submission status: Wrong Answer

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