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:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)
idx = arrA.index(1)
left = arrA[:idx]
right = arrA[idx+1:]
leftnum = len(left)//(K-1) if len(left)%(K-1)==0 else len(left)//(K-1)+1
rightnum = len(right)//(K-1) if len(right)%(K-1)==0 else len(right)//(K-1)+1
ans = leftnum + rightnum
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)
N = N-K
ans = 1
if N<=0:
    num = 0
else:
    num = N//(K-1)+1
ans += num

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

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()))
m=N%K
n=N//K
print(m+n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
len_a = len(a_list)
if len_a <= k:
    print(1)
else:
    ans = len_a - k
    print(ans // (k-1) + ans % (k-1) + 1)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
len_a = len(a_list)
if len_a <= 3:
    print(1)
else:
    ans = len_a - 3
    print(ans // 2 + ans % 2 + 1)

Submission status: Wrong Answer

Solution code:
N, K = 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())
print(1 + (N - K) // (K - 1) + (N - K) % (K - 1))

Submission status: Wrong Answer

Solution code:
import math
import bisect
n,k = map(int,input().split())
li = list(map(int,input().split()))
index = bisect.bisect_left(li, 1)
lef = index
right = n - index - 1
if min(lef,right) >= k -1:
    print(math.ceil((n-1)/(k-1)))
else:
    tmp = max(lef,right) - min(lef,right) - 1
    print(math.ceil((tmp)/(k-1))+1)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = map(int, input().split(' '))
    An = list(map(int, input().split(' ')))
    
    # N, K = 4, 3
    # An = [2, 3, 1, 4]
    
    # N, K = 8, 3
    # An = [7, 3, 1, 8, 4, 6, 2, 5]
    
    
    num = len(An)
    
    print(num // (K-1))
    
    # for i in range(0, len(An), K-1):
    #     print(i)
        
    
    
main()

Submission status: Wrong Answer

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

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

if p % (k-1) + (n-1-p) % (k-1) <= (k-1):
    ans -= 1

print(ans)

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

one = A.index(1)

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

Submission status: Wrong Answer

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

one = A.index(1)

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

Submission status: Wrong Answer

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

zero_index = 0
for i in range(len(A)):
    if A[i] == 1:
        zero_index = i
        break

count = 0
### 1の右側を全部1にする回数を求める
### 右側から数えて K個, K-1個, ... K-1個 でzero_index に届く回数を確かめる
zero_left_index = len(A)

zero_left_index -= K
count += 1
while zero_left_index > zero_index:
    zero_left_index -= (K - 1)
    count += 1

### zero_left_index(全部1になっている列の一番左) を全部1にする回数を求める
if zero_index != 1 and zero_left_index != 0:
    zero_left_index -= K
    count += 1
    while zero_left_index > 0:
        zero_left_index -= (K - 1)
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

idx_1 = A.index(1)
ans = 0
if idx_1 > 0:
    ans += ceil(idx_1 / (K - 1))
if idx_1 < N - 1:
    ans += ceil((N - 1 - idx_1) / (K - 1))

if N <= K:
    ans = max(1, ans - 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()))

idx_1 = A.index(1)
ans = 0
if idx_1 > 0:
    ans += ceil(idx_1 // (K - 1))
if idx_1 < N - 1:
    ans += ceil((N - idx_1) // (K - 1))

print(ans)

Submission status: Wrong Answer

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

if k>=n:
    print("1")
else:
    print(n//(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()]
m = a.index(1)
ans = 0
a = m//(k-1)
ans += a+1
s = (k-1-m%(k-1))+m
l = n-1-s
if l!=0:
  ans += (l-1)//(k-1)+1
if m == 0:
  ans = n//(k-1)
if n==k:
  ans = 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()]
m = a.index(1)
ans = 0
if m!=0:
  ans += (m-1)//(k-1)+1
l = n-1-m
if l!=0:
  ans += (l-1)//(k-1)+1
if n==k:
  ans = 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()]
m = a.index(1)
ans = 0
ans += (m+1)//(k-1)
l = n-1-m
ans += (l+1)//(k-1)
if n==k:
  ans = 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()]
m = a.index(1)

ans = 0
ans += (m+1)//(k-1)
l = n-1-m
m==n-1
ans += (l+1)//(k-1)
if n==k:
  ans = 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()]
m = a.index(1)

ans = 0
ans += (m+1)//2
l = n-1-m
m==n-1
ans += (l+1)//2
if n == 3:
  ans = 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()]
m = a.index(1)

ans = 0
if m<=2:
  ans += 1
else:
  ans += (m+1)//2
l = n-1-m
if m>=n-3:
  ans += 1
else:
  ans += (l+1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
j=-1
for i in range(N):
    if A[i]==1:
        j=i
        break
#print(j)
#print(j,N-j-1)
ans=-(-j)//(K-1)-(-N+j+1)//(K-1)
print(ans)

Submission status: Wrong Answer

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

B = A.index(1)

def left(n):
  if B == 0:
    return 0
  else:
    return B//K+1

def right(n):
  if N-B==0:
    return 0
  else:
    return (N-B)//K+1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

if N == K:
    print(1)
else:
    print(-(-N//(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())
if k >= n:
    print(1)
    exit()
*A, = map(int, input().split())
l = A.index(1)
r = n-l-1
print(-(-l//(k-1))-(-r//(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:
from math import ceil
N,K=map(int, input().split())
A=list(map(int, input().split()))

left=0
right=0
for i in range(N):
  if A[i]==1:
    left=i
    right=N-(i+1)
ans=ceil(left/(K-1))+ceil(right/(K-1))
print(int(ans))

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    apl = a.index(1)
    lena = len(a)
    if apl == 0:
        left = 0
    else:
        if ((apl+1-k) %(k-1)) == 0:
            left = ((apl+1-k) // (k-1)) + 1
        else:
            left = ((apl + 1 - k) // (k - 1)) + 2
    if apl == lena-1:
        right = 0
    else:
        if ((lena-apl-k)%(k-1)) == 0:
            right = ((lena-apl-k)//(k-1))+1
        else:
            right = ((lena - apl - k) // (k - 1)) + 2
    print(right+left)
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    apl = a.index(1)
    lena = len(a)
    if apl == 0:
        left = 0
    else:
        if ((apl+1-k) %(k-1)) == 0:
            left = ((apl+1-k) // (k-1)) + 1
        else:
            left = ((apl + 1 - k) // (k - 1)) + 2
    if apl == lena-1:
        right = 0
    else:
        if ((lena-apl-k)%(k-1)) == 0:
            right = ((lena-apl-k)//(k-1))+1
        else:
            right = ((lena - apl - k) // (k - 1)) + 2
    print(right+left)

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    apl = a.index(1)
    lena = len(a)
    if apl == 0:
        left = 0
    else:
        if ((apl+1-k) %(k-1)) == 0:
            left = (apl+1-k) // (k-1) + 1
        else:
            left = (apl + 1 - k) // (k - 1) + 2
    if apl == lena-1:
        right = 0
    else:
        if ((lena-apl-k)%(k-1)) == 0:
            right = ((lena-apl-k)//(k-1))+1
        else:
            right = ((lena - apl - k) // (k - 1)) + 2
    print(right+left)
resolve()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
*A, = map(int, input().split())
l = A.index(1)
r = n-l-1
print(-(-l//(k-1))-(-r//(k-1)))

Submission status: Wrong Answer

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

left=0
right=0
for i in range(N):
  if A[i]==1:
    left=i
    right=N-(i+1)
ans=ceil(left/(K-1))+ceil(right/(K-1))
print(ans)

Submission status: Wrong Answer

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

id = A.index(1)
ans = math.ceil(id / (K-1))
k = id % (K-1)
ans += max(0, math.ceil((N - 1 - (id+k)) / (K-1)))

tmp = math.ceil((N-1-id)/(K-1))
k = (N-1-id) % (K-1)
tmp += max(0, math.ceil((id-k)/(K-1)))

print(max(1, min(ans, tmp)))

Submission status: Wrong Answer

Solution code:
def resolve():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    apl = a.index(1)
    lena = len(a)
    if apl == 0:
        left = 0
    else:
        if ((apl+1-k) //(k-1)) == 0:
            left = (apl+1-k) // (k-1) + 1
        else:
            left = (apl + 1 - k) // (k - 1) + 2
    if apl == lena-1:
        right = 0
    else:
        if ((lena-apl-k)//(k-1)) == 0:
            right = ((lena-apl-k)//(k-1))+1
        else:
            right = ((lena - apl - k) // (k - 1)) + 2
    print(right+left)
resolve()

Submission status: Wrong Answer

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

id = A.index(1)
ans = math.ceil(id / (K-1))
k = id % (K-1)
ans += max(0, math.ceil((N - 1 - (id+k)) / (K-1)))

tmp = math.ceil((N-1-id)/(K-1))
k = (N-1-id) % (K-1)
tmp += max(0, math.ceil((id-k)/(K-1)))

print(min(ans, tmp))

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:
        ind = i+1
        break
#[0,ind)が1含めて左、[ind,n)が1含めずの右
ans = (ind-3+k)//(k-1)

ans+=(n-ind+k-2)//(k-1)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

Submission status: Wrong Answer

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

id = A.index(1)
ans = math.ceil(id / (K-1))
k = id % (K-1)
ans += math.ceil((N - 1 - (id+k)) / (K-1))
tmp = math.ceil((N-1-id)/(K-1))
k = (N-1-id) % (K-1)
tmp += math.ceil((id-k)/(K-1))
print(min(ans, tmp, math.ceil(id / (K-1)) + math.ceil((N - id - 1)/(K-1))))

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

Submission status: Wrong Answer

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

id = A.index(1)
ans = math.ceil(id / (K-1))
k = id % (K-1)
ans += math.ceil((N - 1 - (id+k)) / (K-1))
tmp = math.ceil((N-1-id)/(K-1))
k = (N-1-id) % (K-1)
tmp += math.ceil((id-k)/(K-1))
print(min(ans, tmp))

Submission status: Wrong Answer

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

id = A.index(1)
ans = math.ceil(id / (K-1))
k = id % (K-1)
ans += math.ceil((N - 1 - (id+k)) / (K-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import ceil

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
index_1 = a.index(1)
ans = 0
if index_1 != 0:
    ans += 1
    if index_1 >= k:
        ans += ceil((index_1 - k + 1) / (k - 1))
if index_1 != (n - 1):
    ans += 1
    if index_1 < (n - k):
        ans += ceil((n - index_1 - k + 1) / (k - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import ceil

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
index_1 = a.index(1)
ans = 0
if index_1 != 0:
    ans += 1
    if index_1 > k:
        ans += ceil((index_1 - k) / (k - 1))
if index_1 != (n - 1):
    ans += 1
    if index_1 < (n - k):
        ans += ceil((n - index_1 - k) / (k - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import ceil

n, k = map(int, readline().split())
a = list(map(int, readline().split()))
index_1 = a.index(1)
ans = 0
if index_1 != 0:
    ans += 1
    if index_1 > 3:
        ans += ceil((index_1 - 3) / 2)
if index_1 != (n - 1):
    ans += 1
    if index_1 < (n - 3):
        ans += ceil((n - index_1 - 3) / 2)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = (int(x) for x in input().split())
input()
ans = n // (k-1)
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
ans = 0
p1 = 0
m = min(seq)
for i in range(n // (k-1)):
    if not all(val == m for val in seq[i*(k-1):i*(k-1)+k]):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
ans = 0
p1 = 0
m = min(seq)
try:
    while True:
        i = seq[p1:].index(m)
        p1 += i+1
        ans += (i+k-2) // (k-1)
except:
    ans += (n - p1+k-2) // (k-1)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if n%(k-1)==0 or n%(k-1)==1:
    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()))

a = A.index(1)
ans = int((a + K - 2) / (K - 1)) + int((N - a - 1 + K - 2) / (K-1))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

min_index = A.index(1)
answer = math.ceil(min_index/(k-1)) + math.ceil((n-min_index-1)/(k-1))

print(answer)

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:
def main():
    import math

    n, k, *a = map(int, open(0).read().split())
    m = min(a)
    i = a.index(1)
    l, r = i, n - i - 1
    ans = math.ceil(l / (k - 1)) + math.ceil(r / (k - 1))
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

if K==2:
  print(N-1)
else:
  print( N//(K-1)  )

Submission status: Wrong Answer

Solution code:
import math

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

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

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:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
def ceil(x,y):
  return (x-1)//y+1

n,k = map(int,input().split())
A = list(map(int,input().split()))
for i,ai in enumerate(A):
  if ai == 1:
    ind1 = i
ans += ceil(n-1-ind1,k-1)
ans += ceil(ind1,k-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:
#C - Minimization
N,K = map(int, input().split())
A = list(map(int, input().split()))

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    x=A.index(1)+1
    ans=-(-(x-1)//(K-1))-(-(N-x)//(K-1))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
minA = min(A)
indexA = A.index(minA)

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
l = r = A.index(1)
ans = 0
while l > 0:
    ans += 1
    l -= (K-1)
while r < N-1:
    ans += 1
    r += (K-1)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,K=map(int,input().split())
L=list(map(int,input().split()))
M=min(L)
tmp=0
ans=float("inf")
for i in range(N):
	if L[i]==M:
		tmp=math.ceil(i/(K-1))
		tmp+=math.ceil((N-1-i)/(K-1))
		ans=min(ans,tmp)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil, floor
#ceil()  # 切り上げ。常にup
#floor()  # 切り捨て。常にdown
#int()  # 常に0に近く（正負で挙動違う）
#round(f),  round(f, 1)  # 四捨五入（第二引数で小数点桁数を指定）

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

left, right = 0, 0
flag = True

for i in range(n):
    if a[i]==1:
        flag = False
        continue

    if flag:
        left += 1
    else:
        right += 1

ans = ceil(left/(k-1)) + ceil(right/(k-1))
print(ans)

Submission status: Wrong Answer

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

if N<=K:
    print(1)
elif (N-K)%(K-1)==0:
    print(1+(N-3)//(K-1))
else:
    print(1+(N-3)//(K-1)+1)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
li = list(map(int, input().split()))
cnt = li.index(1) + 1
ans = 0
ans += (cnt -1 + K -2)//(K-1)
ans += (N - cnt +K-2)//(K-1)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
if n==k:
    print(1)
    exit()
a=list(map(int,input().split()))
for i in range(n):
    if a[i]==1:
        x=i
from math import ceil
before=x
if x<=k-1:
    after=n-k
elif x>=n-k:
    after=1
    before=n-k
else:
    after=n-x-1
print(ceil(before/(k-1))+ceil(after/(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:
        x=i
import math
before=math.ceil(x/(k-1))
after=math.ceil((n-x-1)/(k-1))
print(before+after)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N<=K:
    print(1)
elif (N-3)%(K-1)==0:
    print(1+(N-3)//(K-1))
else:
    print(1+(N-3)//(K-1)+1)

Submission status: Wrong Answer

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

if N<=K:
    print(1)
elif (N-3)%(K-1)==0:
    print((N-3)//(K-1))
else:
    print((N-3)//(K-1)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    min_pos = a.index(1)

    ans = 0
    if min_pos == n - 1:
        pass
    elif n - min_pos <= k:
        ans += 1
    else:
        ans += (n-min_pos-1) // (k-1) + (n-min_pos-1) % (k-1)

    if min_pos == 0:
        pass
    elif min_pos + 1 <= k:
        ans += 1
    else:
        ans += min_pos // (k-1) + min_pos % (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 n==k:
    print(1)
    exit()
# l=[]
ans=0
t=0
for i in range(n):
    if i==n-1:
        if a[i]!=1:
            t+=1
            ans+=ceil(t/(k-1))
        else:
            ans+=ceil(t/(k-1))
            t=0
        continue    
    if a[i]!=1:
        t+=1
    else:
        ans+=ceil(t/(k-1))
        t=0
print(ans)

Submission status: Wrong Answer

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

    min_pos = a.index(1)

    ans = 0
    if min_pos == n - 1:
        pass
    elif min_pos + 1 <= k:
        ans += 1
    else:
        ans += min_pos // (k-1) + min_pos % (k-1)

    if min_pos == 0:
        pass
    elif n - min_pos <= k:
        ans += 1
    else:
        ans += (n-min_pos-1) // (k-1) + (n-min_pos-1) % (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()))
# l=[]
ans=0
t=0
for i in range(n):
    if i==n-1:
        if a[i]!=1:
            t+=1
            ans+=ceil(t/(k-1))
        else:
            ans+=ceil(t/(k-1))
            t=0
        continue    
    if a[i]!=1:
        t+=1
    else:
        ans+=ceil(t/(k-1))
        t=0
print(ans)

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:
        one = i
        break
migi = i
ans = 0
hidari = n-i-1
ans += (migi+k-2)//(k-1)
ans += (hidari+k-2)//(k-1)
print(ans)

Submission status: Wrong Answer

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

    min_pos = a.index(1)

    ans = 0
    if min_pos + 1 <= k:
        ans += 1
    elif min_pos == n - 1:
        pass
    else:
        ans += min_pos // (k-1) + min_pos % (k-1)

    if n - min_pos <= k:
        ans += 1
    elif min_pos == 0:
        pass
    else:
        ans += (n-min_pos-1) // (k-1) + (n-min_pos-1) % (k-1)

    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    l = r = A.index(1)
    count = 0
    if l == 0: count += 0
    elif l < K: count += 1
    else: count += (l - 1) // (K - 1) + 1

    if r == N - 1: count += 0
    elif r >= N - K: count += 1
    else: count += (N - r - 2) // (K - 1) + 1

    print(count)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

    min_pos = a.index(1)

    ans = 0
    if min_pos + 1 >= k:
        ans += 1
    elif min_pos == n - 1:
        pass
    else:
        ans += min_pos // (k-1) + min_pos % (k-1)

    if n - min_pos >= k:
        ans += 1
    elif min_pos == 0:
        pass
    else:
        ans += (n-min_pos-1) // (k-1) + (n-min_pos-1) % (k-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)
j = K-1
l = i
r = N - l - 1
ans, e = divmod(l, j)
if e:
    ans += 1
    r -= (e+1)%K
ans += (r+j-1)//j
print(ans)

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:
        one = i
        break
migi = i+1
hidari = n-i
ans = 0
if migi !=1:
    for i in range(migi):
        if migi-k <=0:
            ans+=1
            break
        else:
            migi-=k-1
            ans+=1
if hidari !=1:
    for i in range(hidari):
        if hidari - k <=0:
            ans+=1
            break
        else:
            ans+=1
            hidari-= k-1
print(ans)

Submission status: Wrong Answer

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

    min_pos = a.index(1)

    ans = min_pos // (k-1) + min_pos % (k-1)
    ans += (n-min_pos-1) // (k-1) + (n-min_pos-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()]
if n<=k:
    print(1)
else:
    k-=1
    print((n+k-1)//k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()