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())
lis = list(map(int, input().split()))
l = lis.index(1)
i = 0
j = 0

while l - i * K + i > 0:
  i += 1

while l + j * K - j < N - 1:
  j += 1
  
print(i + j)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math

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

if n == k:
    ans = 1 
elif n%(k-1)==1:
    ans = math.ceil(n/(k-1))-1
else:
    ans = math.ceil(n/(k-1))
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math

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

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

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 sys
input = sys.stdin.readline


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def argmin(a):
    k = 0
    v = a[0]
    for i in range(len(a)):
        if v > a[i]:
            k = i
            v = a[i]
    return k


def solve(N, K, A):
    ix = argmin(A)
    l = max(0, ix-K+1)
    r = min(N, ix+K)
    if l + K == r:
        ans = 1
    else:
        ans = 2
    while l > 0:
        ans += 1
        l = max(0, l-K+1)
    while r < N:
        ans += 1
        r = min(N, r+K-1)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

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


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def argmin(a):
    k = 0
    v = a[0]
    for i in range(len(a)):
        if v > a[i]:
            k = i
            v = a[i]
    return k


def solve(N, K, A):
    ix = argmin(A)
    l = max(0, ix-K+1)
    r = min(N, ix+K)
    if l + K >= r:
        ans = 1
    else:
        ans = 2
    while l > 0:
        ans += 1
        l = max(0, l-K+1)
    while r < N:
        ans += 1
        r = min(N, r+K-1)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

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


def read():
    N, K = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    return N, K, A


def argmin(a):
    k = 0
    v = a[0]
    for i in range(len(a)):
        if v > a[i]:
            k = i
            v = a[i]
    return k


def solve(N, K, A):
    ix = argmin(A)
    l = max(0, ix-K+1)
    r = min(N, ix+K)
    if l + K >= r:
        return 1
    ans = 2
    while l > 0:
        ans += 1
        l = max(0, l-K+1)
    while r < N:
        ans += 1
        r = min(N, r+K-1)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
from math import ceil
n,k = map(int,input().split())
a=list(map(int,input().split()))
#index = a.index(1)
#left, right = index, n-index-1
#if n!=k: print(ceil(left/(k-1))+ceil(right/(k-1)))
if n!=k: print(ceil(n/(k-1)))
else: print(1)

Submission status: Wrong Answer

Solution code:
from math import ceil
n,k = map(int,input().split())
a=list(map(int,input().split()))
#index = a.index(1)
#left, right = index, n-index-1
#if n!=k: print(ceil(left/(k-1))+ceil(right/(k-1)))
print(ceil(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()))
index = a.index(1)
left, right = index, n-index-1
print(ceil(left/(k-1))+ceil(right/(k-1)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import numpy as np
a=np.array(a)
temp=np.argmin(a)
import math
if n==k:
  print(1)
else:
  print(math.ceil(temp/(k-1))+math.ceil((n-temp-k+temp%(k-1))/(k-1)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import numpy as np
a=np.array(a)
temp=np.argmin(a)
import math
if n==k:
  print(1)
else:
  print(math.ceil(temp/(k-1))+math.ceil((n-temp-1-(temp+1)%(k-1))/(k-1)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
import numpy as np
a=np.array(a)
temp=np.argmin(a)
import math
if n==k:
  print(1)
else:
  print(math.ceil(temp/(k-1))+math.ceil((n-temp-1-temp%(k-1))/(k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

index = a.index(1)

if index==0 or index==n-1:
    t = (n-1)%(k-1)
    if t==0:
        ans=(n-1)//(k-1)
    else:
        ans =(n-1)//(k-1)+1

    print(ans)
else:
    fr = 0
    to =n-1

    if (to-index)%(k-1)==0:
        ans_to=(to-index)//(k-1)
    else:
        ans_to=(to-index)//(k-1) + 1
    
    if index%(k-1)==0:
        ans_fr = index//(k-1)
    else:
        ans_fr = index//(k-1) + 1

    print(ans_fr + ans_to)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
if N==2:
    print(1)
else:
    print(min(ceil(a/(K-1))+ceil((N-1-a)/(K-1)),1+ceil((a-1)/(K-1))+ceil((N-1-(a+1))/(K-1)),ceil((N-1)/(K-1))))

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
if N==2:
    print(1)
else:
    print(min(ceil(a/(K-1))+ceil((N-1-a)/(K-1)),1+ceil((a-1)/(K-1))+ceil((N-1-(a+1))/(K-1))),ceil((N-1)/(K-1)))

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
if N==2:
    print(1)
else:
    print(min(ceil(a/(K-1))+ceil((len(A)-1-a)/(K-1)),1+ceil((a-1)/(K-1))+ceil((len(A)-1-(a+1))/(K-1))))

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
if N==2:
    print(1)
elif a==1 or a==len(A)-2:
    print(1+ceil((len(A)-3)/(K-1)))
elif a==0 or a==len(A)-1:
    print(ceil((len(A)-1)/(K-1)))
else:
    print(min(ceil(a/(K-1))+ceil((len(A)-1-a)/(K-1)),1+ceil((a-1)/(K-1))+ceil((len(A)-1-(a+1))/(K-1))))

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
if a==1 or a==len(A)-2:
    print(1+ceil((len(A)-3)/(K-1)))
elif a==0 or a==len(A)-1:
    print(ceil((len(A)-1)/(K-1)))
else:
    print(min(ceil(a/(K-1))+ceil((len(A)-1-a)/(K-1)),1+ceil((a-1)/(K-1))+ceil((len(A)-1-(a+1))/(K-1))))

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
a=A.index(1)
if a==1 or a==len(A)-2:
    print(1+ceil((len(A)-3)/(K-1)))
elif a==0 or a==len(A)-1:
    print(ceil((len(A)-1)/(K-1)))
else:
    print(min(ceil(a/(K-1))+ceil((len(A)-a)/(K-1)),1+ceil((a-1)/(K-1))+ceil((len(A)-(a+1))/(K-1))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mid = A.index(1)
    count = 1
    r = K - 1
    while r < mid:
        r += (K - 1)
        count += 1

    if r < N - 1:
        l = N - K
        count += 1
        if l > r:
            l -= (K - 1)
            count += 1
    print(count)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mid = A.index(1)
    left = (mid + 1) // (K - 1)
    rightS = left * (K - 1)
    right = (N - rightS) // (K - 1)
    #print(left, right, mid)
    print(left + right)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    mid = A.index(1)
    left = (mid + 1) // (K - 1)
    right = (N - mid) // (K - 1)
    print(left + right)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = min(A)
import math
a = 0
ans = 0
for i in range(N):
  if i == 0 and A[i] == m:
    a = 0
  elif a == i-1 and A[i] == m:
    a = i
  elif A[i] == m:
    if (i-a+1) == K:
      ans += 1
    else:
      ans += math.ceil((i-a+1) / (K-1))
    a = i  
  elif i == N-1:
    if (N-a) == K:
      ans += 1
    else:
      ans += math.ceil((N-a) / (K-1))
    
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = min(A)
import math
a = 0
ans = 0
for i in range(N):
  if A[i] == m and a != i-1 and i != 0:
    if (i-a+1) == K:
      ans += 1
    else:
      ans += math.ceil((i-a+1) / (K-1))
    a = i
    
  elif a == i-1 and A[i] == m:
    a = i
  elif i == 0 and A[i] == m:
    a = 0
  elif i == N-1:
    if (N-a) == K:
      ans += 1
    else:
      ans += math.ceil((N-a) / (K-1))
    
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = min(A)
import math
a = 0
ans = 0
for i in range(N):
  if A[i] == m and a != i-1 and a != 0:
    if (i-a+1) == K:
      ans += 1
    else:
      ans += math.ceil((i-a+1) / (K-1))
    a = i
    
  elif a == i-1 and A[i] == m:
    a = i
  elif i == N-1:
    if (N-a) == K:
      ans += 1
    else:
      ans += math.ceil((N-a) / (K-1))
    
print(ans)

Submission status: Wrong Answer

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

mae = 0
ato = 0
bit = 0
for i in range(n):
    if a[i] != 1 and bit == 0:
        mae += 1
    elif a[i] != 1 and bit == 1:
        ato += 1
    else:
        bit = 1

waru = k-1
ans = (mae+waru-1)//waru + (ato+waru-1)//waru
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
 
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] == 1:
        break
left = len(a[:i])
right = len(a[i + 1:])

ans = left // (k - 1) + right//(k - 1) + int(left%(k - 1) != 0) + int(right%(k - 1) != 0)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

one = A.index(1)
ans = ceil(one/(K-1)) + ceil((N-one-1)/(K-1))
print(ans)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=(a-1)//(b-1)
while (c+1)*(b-1)<=a-1:
  c+=1
if c%(b-1)!=0:
  c+=1
print(c)

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int, input().split())
A = list(map(int, input().split()))
if len(set(A)) == 1:
    print(0)
    exit()
print(1 + math.ceil((n-k)/2))

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

L = A.index(1) + 1
R = N - A.index(1)

if K > min(L, R):
  L = K
  R = N - K + 1

ans = math.ceil((L-1)/(K-1)) + math.ceil((R-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()))

L = A.index(1)
R = N - (L + 1)

ans = math.ceil(L/(K-1)) + math.ceil(R/(K-1))

print(ans)

Submission status: Wrong Answer

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

idx1=A.index(1)

from math import ceil

ans=0

for i in range(K):
  left=idx1-i
  right=left+K-1
  if left<0 or right>N-1:
    continue
  tmp=ceil(left/(K-1))+ceil((N-1-right)/(K-1))+1
  ans=max(ans, tmp)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    idx = A.index(1)
    n_left = idx
    n_right = (N - 1) - idx

    ans = 0
    q, r, = divmod(n_left, K - 1)
    ans += q
    ans += 1 if r > 0 else 0 
    q, r, = divmod(n_right, K - 1)
    ans += q
    ans += 1 if r > 0 else 0 

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

idx1=A.index(1)

from math import ceil

ans=ceil(idx1/(K-1))+ceil((N-1-idx1)/(K-1))
print(ans)

Submission status: Wrong Answer

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

idx1=A.index(1)

from math import ceil

ans=ceil(idx1/2)+ceil((N-idx1)/2)
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = sorted(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()))
import math
if N==K:
  print(1)
else:
  print(math.ceil(N/(K-1)))

Submission status: Wrong Answer

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

if s%k!=0 and n%k!=0:
  print(n//k+1)
elif s%k!=0 and n%k==0:
  print(n//k)
elif s%k==0 and n%k==0:
  print(n//k+1)
else:
  print(n//k+2)

Submission status: Wrong Answer

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

if s%k!=0 and n%k!=0:
  print(n//k+1)
elif s%k!=0 and n%k==0:
  print(n//k)
else:
  print(n//k+1)

Submission status: Wrong Answer

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

if s%k!=0 and n%k!=0:
  print(n//k+1)
elif s%k!=0 and n%k==0:
  print(n//k)
else:
  print(n//k+2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
#最終的にすべて同じ値になるなら、最小値のほうから攻めるべき
#早いソートにしたほうがいいかも。2部探索とか
mini_index=A.index(1)
if N<=K:
    print(1)
else:
    length=K
    count=1
    while(True):
        length+=K-1
        count+=1
        if length>N:
            print(count)
            break

Submission status: Wrong Answer

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

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

import math
print(math.ceil(left/(k-1)) + math.ceil(right/(k-1)))

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,k=l()
A=l()
y=min(A)
x=A.index(y)
ans=x//(k-1)+(x%(k-1)!=0)+(n-x)//(k-1)+((n-x)%(k-1)!=0)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)



n,k=l()
A=l()
if(k==n):
    if(min(A)==max(A)):
        print(0)
        exit()
    print(1)
    exit()
y=min(A)
x=A.index(y)
ans=x//(k-1)+(x%(k-1)!=0)+(n-x)//(k-1)+((n-x)%(k-1)!=0)
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)
    exit()
pos_1 = a.index(1)
left = pos_1
right = n - pos_1 - 1
if left > right:
    left, right = right, left
if left < k - 1:
    right -= k - left - 1
    print(1 + min(n - 1, right + k - 2) // (k - 1))
else:
    print(min(n - 1, left + k - 2) // (k - 1) + min(n - 1, right + k - 2) // (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)
    exit()
pos_1 = a.index(1)
left = pos_1
right = n - pos_1 - 1
if left > right:
    left, right = right, left
if left < k - 1:
    right -= k - left - 1
    print(1 + (right + k - 2) // (k - 1))
else:
    print((left + k - 2) // (k - 1) + (right + k - 2) // (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)
    exit()
pos_1 = a.index(1)
left = pos_1
right = n - pos_1 - 1
if left > right:
    left, right = right, left
if left < k - 1:
    right -= k - left - 1
print((left + k - 2) // (k - 1) + (right + k - 2) // (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)
    exit()
pos_1 = a.index(1)
left = pos_1
right = n - pos_1 - 1
if left > right:
    left, right = right, left
if left < k - 2:
    right -= k - left - 1
print((left + k - 2) // (k - 1) + (right + k - 2) // (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)
    exit()
pos_1 = a.index(1)
left = (pos_1 + k - 2) // (k - 1)
right = (n - pos_1 + k - 3) // (k - 1)
print(left + right)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
[n,k] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a_p = a.index(1)
#print(a_p)
if a_p  % (k-1) == 0 and (n - a_p - 1) % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) )
elif a_p % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) + 1)
else:
    print(a_p//(k-1) + (n - a_p - 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()]
a_p = a.index(1)
#print(a_p)
if a_p  % (k-1) == 0 and (n - a_p - 1) % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) )
elif a_p % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) + 1)
else:
    print((a_p-1)//(k-1) + (n - a_p - 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()]
a_p = a.index(1)
#print(a_p)
if a_p  % (k-1) == 0 and (n - a_p - 1) % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) )
elif a_p % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) + 1)
else:
    print((a_p-1)//(k-1) + (n - a_p - 1) // (k-1))

Submission status: Wrong Answer

Solution code:
[n,k] = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a_p = a.index(1)
if a_p  % (k-1) == 0 and (n - a_p - 1) % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p - 1) // (k-1) )
elif a_p % (k-1) == 0:
    print(a_p//(k-1) + (n - a_p) // (k-1))
else:
    print((a_p-1)//(k-1) + (n - a_p) // (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()]
a_p = a.index(1)
if a_p  % 2 == 0 and (n - a_p - 1) % 2 == 0:
    print(a_p//2 + (n - a_p - 1) // 2 )
elif a_p % 2 == 0:
    print(a_p//2 + (n - a_p) // 2)
else:
    print((a_p-1)//2 + (n - a_p) // 2)

Submission status: Wrong Answer

Solution code:
import math
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
idx0 = A.index(1)
lenL = idx0
lenR = N - idx0 - 1
count = 0
print(math.ceil(lenL/(K-1))+math.ceil(lenR/(K-1)))

Submission status: Wrong Answer

Solution code:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
idx0 = A.index(1)
lenL = idx0
lenR = N - idx0 - 1
count = 0
if lenL%(K-1) == 0 or lenL == 0:
    count += lenL//(K-1)
else:
    count += lenL//(K-1)+1
if lenR%(K-1) == 0 or lenR == 0:
    count += lenR//(K-1)
else:
    count += lenR//(K-1)+1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if n == k:
    print(1)
elif k == 2:
    print(n-1)
else:
    print(math.ceil(n/(k-1)))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

x = l.index(1)
if x % 2 == 0:
    if (n-1 - x) % 2 == 0:
        print(x//2 + (n-1 - x)//2)
    else:
        print(x//2 + (n-1 - x)//2 + 1)
else:
    if (n-1 - x) % 2 == 0:
        print(x//2 +1+ (n-1 - x)//2)
    else:
        print(x//2 +1+ (n-1 - x)//2 + 1)

Submission status: Wrong Answer

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
# input = sys.stdin.readline 
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_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    n, k = i_map()
    num_list = i_list()

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

    one_index = 0

    for i in range(n):
        if num_list[i] == 1:
            one_index = i
            break

    left_num = one_index
    right_num = n - one_index - 1

    count = 0

    count += ceil(left_num/(k-1)) + ceil(right_num/(k-1))

    print(count)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

one = A.index(1)
i = one
ans = None
if one == 0 or one == N-1:
  ans = -(-(N-1) // (K-1))
else:
  left = -(-i // (K-1))
  right = -(-(N - i - 1 - (i % (K-1)))//(K-1))
  ans = left + right

  right = -(-(N - i - 1) // (K-1))
  left = -(-(i - ((N - i - 1)% (K-1)))//(K-1))
  ans = min(ans,left+right)

  
print(ans)

Submission status: Wrong Answer

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

one = A.index(1)
i = one
ans = None
if one == 0 or one == N-1:
  ans = -(-(N-1) // (K-1))
else:
  left = -(-i // (K-1))
  right = -(-(N - i - 1 - (i % (K-1)))//(K-1))
  ans = left + right

  right = -(-(N - i - 1) // (K-1))
  right = -(-(i - ((N - i - 1)% (K-1)))//(K-1))
  ans = left + right

  
print(ans)

Submission status: Wrong Answer

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

one = A.index(1)
i = one
ans = None
if one == 0 or one == N-1:
  ans = -(-(N-1) // (K-1))
else:
  left = -(-i // (K-1))
  right = -(-(N - i - 1 - (i % (K-1)))//(K-1))
  ans = left + right
  
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    IN = [int(_) for _ in input().split()]
    K = IN[1]
    N = IN[0]
    A = [int(_) for _ in input().split()]

    if K >= N:
        print(1)
        return

    v = int(N / (K - 1))
    if N % (K - 1) == 0:
        print(v)
    else:
        print(v+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    IN = [int(_) for _ in input().split()]
    K = IN[1]
    N = IN[0]
    A = [int(_) for _ in input().split()]

    v = int(N / (K - 1))
    if N % (K - 1) == 0:
        print(v)
    else:
        print(v+1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
m = float("inf")
for i in range(n):
    if m > A[i]:
        m = A[i]
        mindex = i
if mindex != 0:
    cnt = (mindex-1)//(k-1) + 2 + (n-mindex-2)//(k-1)
    print(cnt)
else:
    print((n-2)//(k-1)+1)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
m = float("inf")
for i in range(n):
    if m > A[i]:
        m = A[i]
        mindex = i
if mindex != 0:
    cnt = (mindex-1)//(k-1) + 2 + (n-mindex-1)//(k-1)
    print(cnt)
else:
    print((n-1)//(k+1)+1)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
m = float("inf")
for i in range(n):
    if m > A[i]:
        m = A[i]
        mindex = i
cnt = (mindex+1)//(k-1) + (n-mindex)//(k-1)
print(cnt)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
m = float("inf")
for i in range(n):
    if m > A[i]:
        m = A[i]
        mindex = i
cnt = (i+1)//(k-1) + (n-i)//(k-1)
print(cnt)