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()))
ind = A.index(1)
n = ind//(K-1)
if ind%(K-1):
    n += 1
m = (N-1-ind)//(K-1)
if (N-1-ind)%(K-1):
    m += 1
print(n+m)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
a = inpl()
one = a.index(1)
print((one+k-2)//(k-1) + (n-one-1+k-2)//(k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

index = a.index(1)

r = math.ceil((n - index - 1) / (k - 1))
l = math.ceil(index / (k - 1))

print(l + r)

Submission status: Wrong Answer

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

#1の左側の数
hidari=len(a[:s])

#右側の数
migi=len(a[s:])-1


if hidari>1:
    p_h=hidari//(k-1)
    q_h=hidari%(k-1)
    p_m=migi//(k-1)
    q_m=migi%(k-1)
    ans=(p_h+q_h+p_m+q_m)
elif hidari==1:
    p_m=(migi-1)//(k-1)
    q_m=(migi-1)%(k-1)
    ans=(p_m+q_m+1)
elif hidari==0:
    p_m=migi//(k-1)
    q_m=migi%(k-1)
    ans=(p_m+q_m)
    
print(ans)

Submission status: Wrong Answer

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

#1の左側の数
hidari=len(a[:s])

#右側の数
migi=len(a[s:])-1


if hidari>1:
    p_h=hidari//2
    q_h=hidari%2
    p_m=migi//2
    q_m=migi%2
    ans=(p_h+q_h+p_m+q_m)
elif hidari==1:
    p_m=(migi-1)//2
    q_m=(migi-1)%2
    ans=(p_m+q_m+1)
elif hidari==0:
    p_m=migi//2
    q_m=migi%2
    ans=(p_m+q_m)
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
s=len(a)
p=(s-1)//2
q=(s-1)%2
if s<4:
    print(1)
else:
    print(p+q)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
s=len(a)
p=s//2
q=s%2
if s<4:
    print(1)
else:
    print(p+q)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
i = a.index(1)
ans = (min(i, n - k) + k - 2) // (k - 1) + (max(n - 1 - i, k - 1) + k - 2) // (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)
ans = (i + k - 2) // (k - 1) + (n - i - 1 + k - 2) // (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:
# coding: utf-8
import math
n, k = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n):
    if A[i]==1:
        cnt=i

l = i
r = n - i - 1
r -= l%(k-1)
print(math.ceil(l/k) + math.ceil(r/k))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n, k = map(int,input().split())
A = list(map(int,input().split()))
for i in range(n):
    if A[i]==1:
        cnt=i

l = i
r = n - i - 1
r -= l%(k-1)
print(l//k + r//k)

Submission status: Wrong Answer

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

if n <= k:
    print(1)
elif n <= k*2-1:
    print(2)
else:
    cnt = 2
    m = n - (k-1)*2
    # m = n
    while m >= 0:
        m -= k+1
        cnt += 1
    print(cnt)

Submission status: Wrong Answer

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

if n <= k:
    print(1)
elif n <= k*2-1:
    print(2)
else:
    cnt = 0
    # m = n - (k-1)*2
    m = n
    while m >= 0:
        m = m - k + 1
        cnt += 1
    print(cnt-1)

Submission status: Wrong Answer

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

if n <= k:
    print(1)
elif n <= (k-1)*2:
    print(2)
else:
    cnt = 2
    m = n - (k-1)*2
    while m >= 0:
        m -= k + 1
        cnt += 1
    print(cnt)
    # one = al.index(1)
    # if one == k+1 or (n-one) == k+1:
    #     print(cnt + 1)
    # else:
    #     print(cnt)

Submission status: Wrong Answer

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

if n <= k:
    print(1)
elif n <= (k-1)*2:
    print(2)
else:
    cnt = 2
    m = n - (k-1)*2
    while m >= 0:
        m -= k + 1
        cnt += 1
    one = al.index(1)
    if one == k+1 or (n-one) == k+1:
        print(cnt + 1)
    else:
        print(cnt)

Submission status: Wrong Answer

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

print(-(-n//(k-1)) if k < n else 1)

Submission status: Wrong Answer

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

print(-(-n//(k-1)) if n != k else 1)

Submission status: Wrong Answer

Solution code:
def resolve():
    n,k=map(int,input().split())
    a=list(map(int,input().split()))
    im=-1
    for i in range(n):
        if a[i]==1:
            im=i
    print((im+k-2)//(k-1)+(n-1-im+k-2)//(k-1))
resolve()

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    a = input_list()
    if (n - 1) % (k - 1) == 0:
        print((n-1) // (k-1))
    else:
        v = (n-1) // (k-1)
        print(v + (n - 1) % (k - 1))


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import collections
import itertools

def main():
    n, k = input_list()
    a = input_list()
    if (n - 1) % (k - 1) == 0:
        print(n-1 // k-1)
    else:
        v = (n-1) // (k-1)
        print(v + (n - 1) % (k - 1))


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# author:  Taichicchi
# created: 18.09.2020 21:22:11

import sys

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

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


print(N // (K - 1))

Submission status: Wrong Answer

Solution code:
import sys

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

ans = (N-1)//(K-1) + 1
if K != N:
    print(ans)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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


pos_1 = 0 
for i in range(N):
    if A_list[i] == 1:
        pos_1 = i

ans1 = math.ceil((pos_1)/(K-1)) + math.ceil((N-1-pos_1)/(K-1))
ans2 = math.ceil((pos_1-1)/(K-1)) + math.ceil((N-1-pos_1+1)/(K-1))
ans3 = math.ceil((pos_1+1)/(K-1)) + math.ceil((N-1-pos_1-1)/(K-1))

if K != N:
    print(min(ans1, ans2, ans3))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import sys

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

pos = A.index(1)
# print(pos)
ans = 0
left = pos
while 0 < left:
    left -= K - 1
    ans += 1
right = pos
while right < N - 1:
    right += K - 1
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

pos = A.index(1)
print(pos)
ans = 0
left = pos
while 0 < left:
    left -= K - 1
    ans += 1
right = pos
while right < N - 1:
    right += K - 1
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

pos_1 = 0 
for i in range(N):
    if A_list[i] == 1:
        pos_1 = i

ans1 = math.ceil((pos_1)/(K-1)) + math.ceil((N-1-pos_1)/(K-1))
ans2 = math.ceil((pos_1-1)/(K-1)) + math.ceil((N-1-pos_1+1)/(K-1))
ans3 = math.ceil((pos_1+1)/(K-1)) + math.ceil((N-1-pos_1-1)/(K-1))

if K != N:
    print(min(ans1, ans2, ans3))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

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

pos_1 = 0 
for i in range(N):
    if A_list[i] == 1:
        pos_1 = i

ans1 = math.ceil((pos_1)/(K-1)) + math.ceil((N-1-pos_1)/(K-1))
ans2 = math.ceil((pos_1-1)/(K-1)) + math.ceil((N-1-pos_1+1)/(K-1))
ans3 = math.ceil((pos_1+1)/(K-1)) + math.ceil((N-1-pos_1-1)/(K-1))
print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

Solution code:
import math

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

pos_1 = 0 
for i in range(N):
    if A_list[i] == 1:
        pos_1 = i

ans = math.ceil((pos_1)/(K-1)) + math.ceil((N-1-pos_1)/(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)
else:
    print(-(-n//(k-1)))

Submission status: Wrong Answer

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

ind = A.index(1)
ans = 0
if n==k:
    print(1)
    exit()
if ind != 0:
    ans += -(-ind//(k-1))
if ind != n-1:
    ans += -(-(n-1-ind)//(k-1))

print(ans)

Submission status: Wrong Answer

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

ind = A.index(1)
ans = -(-(n-1-ind)//(k-1)) + -(-ind//(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:
n,k = map(int,input().split())
a = list(map(int,input().split()))

ni = a.index(1)
if k >= len(a):
    ans = 1
else:
    ans = ni//(k-1)+1 +(n-ni-1 - ni%(k-1))//(k-1)
print(ans)

Submission status: Wrong Answer

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

ni = a.index(1)

ans = ni//(k-1)+1 +(n-ni-1 - (ni-1)%(k-1))//(k-1)
print(ans)

Submission status: Wrong Answer

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

ni = a.index(1)

ans = ni//(k-1)+1 +(n-ni-1 + (ni-1)%(k-1))//(k-1)
print(ans)

Submission status: Wrong Answer

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

ni = a.index(1)

ans = ni//(k-1)+1 +(n-ni-1 + ni%(k-1))//(k-1)+1
print(ans)

Submission status: Wrong Answer

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

ni = a.index(1)

ans = ni//(k-1)+1 +(n-ni-1 + ni%(k-1))//(k-1)
print(ans)

Submission status: Wrong Answer

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

ni = a.index(1)

ans = ni//(k-1) +(n-ni-1 + ni%(k-1))//(k-1)
print(ans)

Submission status: Wrong Answer

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

ni = a.index(1)

ans = ni//(k-1) +(n-ni+1 + ni%(k-1))//(k-1)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
arr = list(map(int,input().split()))
x = arr.index(1)
L = x
R = n - x - 1
cnt = math.ceil(L / (k - 1))
cnt += math.ceil(R / (k - 1))
print(cnt)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
r_count = 0
ans = 0
for i in range(N):
  if A[i] == 1:
    break
  else:
    r_count += 1
    
l_count = N - r_count - 1

if r_count == 0:
    pass
elif r_count <= K-1:
  ans += 1
elif r_count % (K-1) == 0:
  ans += r_count//(K-1)
else:
  ans += r_count//(K-1) + 1

if l_count == 0:
    pass
elif l_count <= K-1:
  ans += 1
elif l_count % (K-1) == 0:
  ans += l_count//(K-1)
else:
  ans += l_count//(K-1) + 1
  
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
a = list(map(int,input().split()))
num = a.index(1)
n = M-1
left1= (num)//(M-1)
left2 = (num)%(M-1)
right = (N-num-1-left2)//(M-1)
right2 = (N-num-1-left2)%(M-1)
if left2 !=0:
  left1 += 1
if right2 !=0:
  right += 1
print(left1+right)

Submission status: Wrong Answer

Solution code:
import math

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

min_ind = a.index(min(a))

start = sorted([min_ind - x for x in range(k) if min_ind - x >= 0])
end = [s+k-1 for s in start]

ans = 10**6
for s, e in zip(start, end):
    ans = min(ans, math.ceil(len(a[:s])/2) + math.ceil(len(a[e+1:])/2))

print(ans+1)

Submission status: Wrong Answer

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

if n <= k:
    ans = 1
else:
    if n%k!=0:
        ans = math.ceil(n/(k-1))
    else:
        ans = math.ceil(n/(k-1))+2

print(ans)

Submission status: Wrong Answer

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

if n <= k:
    ans = 1
else:
    ans = math.ceil(n/(k-1))

print(ans)

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()
    a = i_list()
    one = a.index(1)
    left = one
    right = n - left - 1
    print(math.ceil(left/(k-1)) + math.ceil(right/(k-1)))


if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()
    a = i_list()
    one = a.index(1)
    ans = 0
    left = one
    right = n - left - 1
    print(math.ceil(left/2) + math.ceil(right/2))




if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

cnt=1
num=3
while num<n:
  num+=2
  cnt+=1
  
print(cnt)

Submission status: Wrong Answer

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

ans = int((N-1)/(K-1))

if (N-1)%(K-1) == 0:
    print(ans+1)
else:
    print(ans)

Submission status: Wrong Answer

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

if N == K:
    print(1)
elif N < K*2:
    print(2)
else:
    a = []
    cnt = 0
    for i in range(0, len(A)-K+1, K-1):
        cnt += 1
        a.append(A[i:K+i])
    a = list(set(list(itertools.chain.from_iterable(a))))
    cnt += len(A)-len(a)
    print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min_ind = a.index(min(a))

l = min_ind
r = n - (min_ind + 1)

b, c = divmod(l, k-1)
d, e = divmod(r, k-1)

if c + e >= k-1:
    print(math.ceil(l/(k-1)) + math.ceil(r/(k-1)) - 1)
else:
    print(math.ceil(l/(k-1)) + math.ceil(r/(k-1)))

Submission status: Wrong Answer

Solution code:
import math

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

min_ind = a.index(min(a))

l = a[:min_ind]
r = a[min_ind+1:]

print(math.ceil(len(l)/(k-1)) + math.ceil(len(r)/(k-1)))

Submission status: Wrong Answer

Solution code:
import math

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

min_ind = a.index(min(a))

l = min_ind
r = n - (min_ind + 1)

print(math.ceil(l/(k-1)) + math.ceil(r/(k-1)))

Submission status: Wrong Answer

Solution code:
import math

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

min_a = min(a)

r = n - (a.index(min_a) + 1)
l = a.index(min_a)

print(math.ceil(r/(k-1)) + math.ceil(l/(k-1)))

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split())
    a_lst = list(map(int, input().split()))
    min_index = a_lst.index(1)

    before = 0
    tmp1 = 0
    while tmp1 < min_index:
        before += 1
        tmp1 = (k - 1) * before

    after = 0
    tmp2 = 0
    while tmp2 < n - 1 - min_index:
        after += 1
        tmp2 = (k - 1) * after

    answer = before + after
    print(answer)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
As = list(mapint())

times = -(-N//(K-1))
print(times)

Submission status: Wrong Answer

Solution code:
#34 C - Minimization
N,K = map(int,input().split())
A = list(map(int,input().split()))

print(N//(K-1))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

def ceil(a, b):
    return (a + b - 1) // b

n, k = inm()
a = inl()
start = a.index(1)
print(ceil(start, k-1) + ceil(n-start-1, k-1))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, k = inm()
a = inl()
print((n + k - 1) // (k-1) - 1)

Submission status: Wrong Answer

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

ans = 1
ptr = A.index(1)
left = max(ptr - 1, 0)
right = max(n - ptr - 2, 0)

ans += left // (k - 1)
if left % (k - 1) > 0:
    ans += 1

ans += right // (k - 1)
if right % (k - 1) > 0:
    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()]

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

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,k = LI()
    a = LI()
    index = a.index(1)
    left = index
    right = n-index
    ans = float("inf")

    for i in range(k):
        cl = left-i
        cr = right-(k-i-1)
        if cl < 0 or cr < 0:
            continue
        
        cntl = (cl+k-1)//(k-1) if cl!=0 else 0
        cntr = (cr+k-1)//(k-1) if cr!=0 else 0
        cnt = cntl+cntr
        ans = min(ans,cnt)

    print(ans)
    
main()

Submission status: Wrong Answer

Solution code:
import math as mt
N,M=list(map(int,input().split()))
if N==M:
  print(1)
  exit()
L=list(map(int,input().split()))
print(mt.floor((N-M)//(M-1))+2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

C=[]
c=0
mina=min(A)
for i in range(len(A)):
    if mina==A[i]:
        C.append(c)
        c=0
    else:
        c+=1
C.append(c)

ans=0
for i in range(len(C)):
    ans += (C[i]+k-2)//(k-1)
ans = min(ans, (n+k-2)//(k-1))
print(ans)

Submission status: Wrong Answer

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

C=[]
c=0
mina=min(A)
for i in range(len(A)):
    if mina==A[i]:
        C.append(c)
        c=0
    else:
        c+=1
C.append(c)

ans=0
for i in range(len(C)):
    if C[i]!=0:
        ans += (C[i]+k-2)//(k-1)

print(ans)

Submission status: Wrong Answer

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

C=[]
c=0
mina=min(A)
for i in range(len(A)):
    if mina==A[i]:
        C.append(c)
        c=0
    else:
        c+=1
C.append(c)

ans=0
for i in range(len(C)):
    ans += (C[i]+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()))
saishou=A.index(1)
if K==N:
    print(1)
elif saishou==0 or saishou==N-1:
    answer=math.ceil((N-1)/(K-1))
    print(answer)
elif saishou+1<=K:
    answer=1+math.ceil((N-K)/(K-1))
    print(answer)
elif N-saishou<=K:
    answer=math.ceil((N-K)/(K-1))+1
    print(answer)
else:
    print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
saishou=A.index(1)
if saishou==0 or saishou==N-1:
    answer=math.ceil((N-1)/(K-1))
    print(answer)
elif saishou+1<=K:
    answer=1+math.ceil((N-K)/(K-1))
    print(answer)
elif N-saishou<=K:
    answer=math.ceil((N-K)/(K-1))+1
    print(answer)
else:
    print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
saishou=A.index(1)
if saishou==0:
    answer=math.ceil((N-1)/(K-1))
    print(answer)
elif saishou+1<=K:
    answer=1+math.ceil((N-K)/(K-1))
    print(answer)
elif N-saishou<=K:
    answer=math.ceil((N-K)/(K-1))+1
    print(answer)
else:
    print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
saishou=A.index(1)
if saishou==0:
    answer=math.ceil((N-1)/(K-1))
    print(answer)
elif saishou+1<=K:
    answer=1+math.ceil((N-1-saishou)/(K-1))
    print(answer)
elif N-saishou<=K:
    answer=math.ceil(saishou/(K-1))+1
    print(answer)
else:
    print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
saishou=A.index(1)
if saishou==0:
    answer=math.ceil((N-1)/(K-1))
    print(answer)
else:
    print(math.ceil(saishou/(K-1))+math.ceil((N-1-saishou)/(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(i/(K-1))+math.ceil((N-1-i)/(K-1)))

Submission status: Wrong Answer

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

min_place = an.index(min(an))
left = math.ceil((min_place)/(k-1))
if (min_place+1)<k:
    min_place2 = k
else:
    min_place2 = min_place
right = math.ceil((n-min_place2-1)/(k-1))
Ans = left + right
if Ans==0:
    Ans += 1
print(Ans)

Submission status: Wrong Answer

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

min_place = an.index(min(an))
left = math.ceil((min_place)/(k-1))
if (min_place+1)<k:
    min_place2 = k
else:
    min_place2 = min_place
right = math.ceil((n-min_place2-1)/(k-1))
Ans = left + right
print(Ans)

Submission status: Wrong Answer

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

min_place = an.index(min(an))
left = math.ceil((min_place)/(k-1))
right = math.ceil((n-min_place-1)/(k-1))
Ans = left + right
print(Ans)

Submission status: Wrong Answer

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

min_place = an.index(min(an))
left = (min_place+1)//2
right = (n-min_place)//2
Ans = left + right
print(Ans)

Submission status: Wrong Answer

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

left = math.ceil(a.index(min(a)) / (k - 1))
surplus = (k-(a.index(min(a)) % (k - 1))+1) % k
right = math.ceil((len(a)-a.index(min(a))-surplus)/(k-1))
print(left+right)

Submission status: Wrong Answer

Solution code:
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-1-i

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

Submission status: Wrong Answer

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

index = a.index(1)
cnt = 0

if (n==k):
    print(1)
else:
    if index <= (k - 1):
        cnt += 1
        i = k - 1
        while i <= (len(a) - 2):
            i += (k-1)
            cnt += 1
    elif index >= (n - k):
        cnt += 1
        i = n - k
        while i >= 1:
            i -= (k-1)
            cnt += 1
    else:
        i = index
        while i >= 1:
            i -= (k-1)
            cnt += 1

        i = index
        while i <= (len(a) - 2):
            i += (k-1)
            cnt += 1

    print(cnt)

Submission status: Wrong Answer

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

index = a.index(1)
cnt = 0

i = index
while i >= 1:
    i -= (k-1)
    cnt += 1

i = index
while i <= (len(a) - 2):
    i += (k-1)
    cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
ans =  0
if(N==K):
    print(1)
else:
    one_index=A.index(1)
    right = one_index
    left = N-one_index-1
    ans+=right//(K-1)
    if(left>=right-ans*(K-1)):
        left -= right-ans*(K-1)
        ans+=left//(K-1)
        if(left%(K-1)!=0):
            print(ans+1)
        else:
            print(ans)
    else:
        print(ans+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

A=[int(b) for b in a]

place=A.index(min(A))

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

Submission status: Wrong Answer

Solution code:
import math

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

A=[int(b) for b in a]

place=A.index(min(A))

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

Submission status: Wrong Answer

Solution code:
import math

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

A=[int(b) for b in a]

place=A.index(min(A))

if place==0:
    answer=N//2
    print(answer)
else:
    answer=math.ceil((N-place)/2)
    answer+=math.ceil(place/2)
    print(answer)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
B = min(A)
cnt = 0
for i in range(N-K+1):
    if A[i] != B:
        for j in range(K-1):
            A[i+j] = B
        cnt += 1
for i in A[N-K+1:N+1]:
    if i != B:
        cnt += 1
        break
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
for i,num in enumerate(a):
    if num==1:
        break
j = i % (k-1)
ans = 0
if j>0:
    ii = i+(k-1-j)
    ans = i//(k-1) + 1
else:
    ii = i-1
    ans = i//(k-1)
ans += (n-1-i) // (k-1) + int((n-1-i)%(k-1)!=0)
print(ans)