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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

index = A_list.index(1)

left_list = A_list[:index]
right_list = A_list[index+1:]

if len(left_list) > len(right_list):
  A_list = A_list[::-1]
  index = A_list.index(1)

  left_list = A_list[:index]
  right_list = A_list[index+1:]

if len(left_list) < K-1:
  left_count = 1
  right_list = right_list[(K-1-len(left_list)):]
  right_count = math.ceil(len(right_list) / (K-1))
else:
  left_count = math.ceil(len(left_list) / (K-1))
  right_count = math.ceil(len(right_list) / (K-1))

print(left_count + right_count)

Submission status: Wrong Answer

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

index = A_list.index(1)

left_list = A_list[:index]
right_list = A_list[index+1:]

if len(left_list) < K-1:
  left_count = 1
  right_list = right_list[(K-1-len(left_list)):]
  right_count = math.ceil(len(right_list) / (K-1))
else:
  left_count = math.ceil(len(left_list) / (K-1))
  right_count = math.ceil(len(right_list) / (K-1))

print(left_count + right_count)

Submission status: Wrong Answer

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

index = A_list.index(1)

left_list = A_list[:index]
right_list = A_list[index+1:]

left_count = math.ceil(len(left_list) / (K-1))
right_count = math.ceil(len(right_list) / (K-1))

print(left_count + right_count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
idx = A.index(1)
if N == K:
    print(1)
else:
    print(math.ceil(idx/(K-1))+math.ceil((N-idx-1)/(K-1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
answer = 50001
while True:
    if n <= k + (k - 1) * (answer - 1):
        answer -= 1
    else:
        break

print(answer + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
x = a.index(1)
left = x
right = n - x - 1

ans = n
for i in range(k):
    if left < i:
        continue
    a = left - i + 1
    if right - k + 2 + i < 0:
        continue
    b = right - k + 2 + i
    w = a//(k-1) + b//(k-1)
    ans = min(ans, w)
print(ans + 1)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
x = a.index(1)
left = x
right = n - x - 1

ans = n
for i in range(k):
    if left < i:
        continue
    a = left - i + 1
    if right - k + 2 + i < 0:
        continue
    b = right - k + 2 + i
    print(a, b)
    w = a//(k-1) + b//(k-1)
    ans = min(ans, w)
print(ans + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c = 0
while N > 0:
    c += 1
    N -= K-1
print(c)

Submission status: Wrong Answer

Solution code:
n, k = list(map(int, input().split()))
a = input()
left = a.index('1')
right = n -left -1
b = k-1
p1 = (left+1)//b + (right+1)//b
p2 = 1 + left//b + right//b
print(min(p1, p2))

Submission status: Wrong Answer

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,K=LI()
LI()
if N%(K-1) == 1:
    if K-1 == 1:
        print(N-1)
    else:
        print(N//(K-1))

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,K=LI()
LI()
if N%(K-1) == 1:
    print(N//(K-1))
else:
    print(N//(K-1) + (1 if N%(K-1) else 0))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import ceil


def main():
    length, section_range = map(int, input().split(" "))
    numbers = list(map(int, input().split(" ")))

    if length == section_range:
        print(1)
    else:
        print(ceil((length - 1) / section_range) + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

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

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

Submission status: Wrong Answer

Solution code:
import math

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

    l = r = A.index(1)
    ans = 0
    while r < N-1 or l > 0:
        if r < N-1:
            ans += 1
            r += K-1
        
        if l > 0:
            ans += 1
            l -= K+1

    print(ans)

main()

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:
import math

def main():
    N, K = map(int, input().split())
    input()
    print(math.floor(N/(K-1)))

main()

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

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

idx = a.index(1)
num_l = idx
num_r = n - idx - 1
#print(num_l, num_r)

if num_l == 0 or num_r == 0:
    print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))
elif num_l < k-1:
    print(math.ceil(num_l / (k - 1)) + math.ceil((num_r - k + 1 + num_l) / (k - 1)))
elif num_r < k-1:
    print(math.ceil((num_l - k + 1 + num_r) / (k - 1)) + math.ceil(num_r / (k - 1)))
else:
    print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

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

idx = a.index(1)
num_l = idx
num_r = n - idx - 1
print(num_l, num_r)

if num_l == 0 or num_r == 0:
    print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))
elif num_l < k-1:
    print(math.ceil(num_l / (k - 1)) + math.ceil((num_r - k + 1 + num_l) / (k - 1)))
elif num_r < k-1:
    print(math.ceil((num_l - k + 1 + num_r) / (k - 1)) + math.ceil(num_r / (k - 1)))
else:
    print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]

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

idx = a.index(1)
print(math.ceil(idx / (k-1)) + math.ceil((n - idx - 1) / (k-1)))

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = [int(_) for _ in input().split()]
idx = a.index(1)
num_l = idx
num_r = n - idx - 1
ans = math.ceil(num_l / (k-1)) + math.ceil(num_r / (k-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(n//(k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

idx = a.index(1)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
i = idx
while i > 0:
    i = i - K + 1
    ans += 1

i = idx
while i < N - 1:
    i = i + K - 1
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
idx = a.index(1)
l = math.ceil(idx / (k - 1))
r = math.ceil((n - idx - 1) / (k - 1))
print(1 if n == k else l + r)

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
idx = a.index(1)
l = math.ceil(idx / (k - 1))
r = math.ceil((n - idx - 1) / (k - 1))
print(l + r)

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()))
cnt = 0

if n == k:
  cnt = int(n / k)
else:
  while n > 0:
    n = n - (k-1)
    cnt +=1
  
print(cnt)

Submission status: Wrong Answer

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

if n % k == 0:
  cnt = int(n / k)
else:
  while n > 0:
    n = n - (k-1)
    cnt +=1
  
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
nk = list(map(int,input().split()))
A = list(map(int,input().split()))
n = nk[0]
k = nk[1]
for i in range(n):
  if A[i] == 1:
    index = i
lef = index
rig = n -lef - 1
if lef % (k-1)== 0:
  lefs = lef // (k-1)
else:
  lefs = lef // (k-1) +1
if rig % (k-1)== 0:
  rigs = rig // (k-1)
else:
  rigs = rig // (k-1) +1
ans = rigs + lefs
print(ans)

Submission status: Wrong Answer

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

idx = a.index(1)


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


aa = ceil((idx), k-1)
bb = ceil((n-idx), k-1)
print(aa+bb)

Submission status: Wrong Answer

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

idx = a.index(1)


def tmp(a, b):
    ans = 0
    while(a):
        a = a-b
        if a != 0:
            a += 1
        ans += 1
    return ans


aa = tmp((idx+1), k)
bb = tmp((n-idx+1), k)
print(aa+bb)

Submission status: Wrong Answer

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

idx = a.index(1)


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


print(ceil((idx+1), k) + ceil((n-idx+1), k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
if idx == 0:
    print(-(-len(a[(idx + 1):]) // (k - 1)))
elif idx == (n - 1):
    print(-(-len(a[:idx]) // (k - 1)))
else:
    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()))
idx = a.index(1)
if idx == 0:
    print(ceil(len(a[(idx + 1):]) / (k - 1)))
elif idx == (n - 1):
    print(ceil(len(a[:idx]) / (k - 1)))
else:
    ans = (ceil(len(a[:idx]) / (k - 1))) + (ceil(len(a[(idx + 1):]) / (k - 1)))
    if (k - 1) < len(a[:idx]) % (k - 1) + len(a[(idx + 1):]) % (k - 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 = a.index(1)
if idx == 0:
    print(ceil(len(a[(idx + 1):]) / (k - 1)))
elif idx == (n - 1):
    print(ceil(len(a[:idx]) / (k - 1)))
else:
    ans = (ceil(len(a[:idx]) / (k - 1))) + (ceil(len(a[(idx + 1):]) / (k - 1)))
    if (k - 1) <= len(a[:idx]) % (k - 1) + len(a[(idx + 1):]) % (k - 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 = a.index(1)
if idx == 0:
    print(ceil(len(a[(idx + 1):]) / (k - 1)))
elif idx == (n - 1):
    print(ceil(len(a[:idx]) / (k - 1)))
else:
    print((ceil(len(a[:idx]) / (k - 1))) + (ceil(len(a[(idx + 1):]) / (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))

Submission status: Wrong Answer

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


def calc(n, k):
    cnt = 0
    while True:
        tmp = n // 3
        n = tmp + n % 3
        cnt += tmp
        if n <= K:
            cnt += 1
            return cnt


if len(nums) <= K:
    print(1)
else:
    print(calc(N, K))

Submission status: Wrong Answer

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

minpos = 0
for i in range(0, n):
  if a[i] == 1: minpos = i
print((minpos + k - 2) // (k - 1) + (n - minpos - 1 + k - 2) // (k - 1))

Submission status: Wrong Answer

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

minpos = 0
for i in range(0, n):
  if a[i] == 1: minpos = i
print((minpos + k - 2) / (k - 1) + (n - minpos - 1 + k - 2) / (k - 1))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
m=A.index(1)
ans=0
l=m
#print(l)
if N==K:
    print(1)
else:
    while l>0:
        ans+=1
        l-=(K-1)
    l=m
    while l<N-1:
        ans+=1
        l+=(K-1)
    print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
m=A.index(1)
ans=0
l=m
#print(l)
while l>0:
    ans+=1
    l-=(K-1)
l=m
#print(ans)
while l<N-1:
    ans+=1
    l+=(K-1)
print(ans)

Submission status: Wrong Answer

Solution code:

import math

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

cnt = 0
for i in range(N):
    if A[i] == 1:
        L = i
        R = (N - i - 1)
        if L == 0:
            cnt += 0
        elif L < K:
            cnt += 1
        else:
            #cnt += (math.ceil(L / (K - 1)))
            cnt += (L / (K - 1))
        if R == 0:
            cnt += 0
        elif R < K:
            cnt += 1
        else:
            cnt += (R / (K - 1))            

            
#print(L,R)
print(cnt)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 1
if N == K:
    print(1)
    exit()
else:
    if (N-K+1)%K == 0:
        ans += N-K+1
    else:
        ans += (N-K+1)%K+1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

cnt = 0
for i in range(N):
    if A[i] == 1:
        L = i
        R = (N - i - 1)
        if L == 0:
            cnt += 0
        elif L < K:
            cnt += 1
        else:
            cnt += (math.ceil(L / (K - 1)))
        if R == 0:
            cnt += 0
        elif R < K:
            cnt += 1
        else:
            cnt += (math.ceil(R / (K - 1)))   
print(cnt)

Submission status: Wrong Answer

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

cnt = 0
for i in range(N):
    if A[i] == 1:
        L = i
        R = (N - i - 1)
        if L == 0:
            cnt += 0
        elif L < K:
            cnt += 1
        else:
            cnt += (L - K + 1)
        if R == 0:
            cnt += 0
        elif R < K:
            cnt += 1
        else:
            cnt += (R - K + 1)   
print(cnt)

Submission status: Wrong Answer

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

i = a.index(1)
mar = k - 1  # max replacible count

le = (i + mar - 1) // mar  # [0,i)
ri = (n - i - 1 + mar - 1) // mar  # [i+1,n)

print(le + ri)

Submission status: Wrong Answer

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

def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    x = A.index(1)
    l = -((-x) // (K - 1))
    lmod = (x + 1) % K
    r = -(-(N - x - 1 - lmod) // (K - 1))
    print(l + r)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    x = A.index(1)
    l = -(-(x // (K - 1)))
    lmod = (x + 1) % K
    r = -(-(N - x - 1 - lmod) // (K - 1))
    print(l + r)




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    x = A.index(1)
    print(-(-x // (K - 1)) + -(-(N - x - 1) // (K - 1)))




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    x = A.index(1)
    print(x // (K - 1) + (N - x) // (K - 1))




if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
mini = a.index(1)
l = mini // (k-1)
lm = mini % (k-1)
r = (n - mini - 1) // (k-1)
rm = (n - mini - 1) % (k-1)
# print(l, r, lm, rm)
print(l + r + ((lm + rm + 1) // k + ((lm + rm + 1) % k != 0)))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
mini = a.index(1)
l = mini // (k-1)
lm = mini % (k-1)
r = (n - mini - 1) // (k-1)
rm = (n - mini - 1) % (k-1)
# print(l, r, lm, rm)
print(l + r + ((lm + rm + 1) // (k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc_process_num(n):
    if n == 1:
        return 0
    elif n <= K:
        return 1
    else:
        return 1 + int((n - K) / (K - 1)) if (n - K) % (K - 1) == 0 else 2 + int((n - K) / (K - 1))


N, K = map(int, input().split())
A = list(map(int, input().split()))
idx_minA = A.index(min(A)) + 1

if N <= K:
    print(1)
else:
    print(calc_process_num(idx_minA) + calc_process_num(N - idx_minA + 1))

Submission status: Wrong Answer

Solution code:
import math


def calc_process_num(n):
    return 1 + math.ceil((n - K)/(K - 1))


N, K = map(int, input().split())
A = list(map(int, input().split()))
idx_minA = A.index(min(A)) + 1
if N <= K:
    print(1)
else:
    print(calc_process_num(idx_minA) + calc_process_num(N - idx_minA + 1))

Submission status: Wrong Answer

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

x = N-K
x, m = divmod(x, (K-1))
print(1+x+m)

Submission status: Wrong Answer

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

num_1=a.index(1)
if num_1%(k-1)==0:
    left=num_1//(k-1)
else:
    left=num_1//(k-1)+1
if (n-1-num_1)%(k-1)==0:
    right=(n-1-num_1)//(k-1)
else:
    right=(n-1-num_1)//(k-1)+1
ans=left+right
print(ans if n>=k else 1)

Submission status: Wrong Answer

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

num_1=a.index(1)
if num_1%(k-1)==0:
    left=num_1//(k-1)
else:
    left=num_1//(k-1)+1
if (n-1-num_1)%(k-1)==0:
    right=(n-1-num_1)//(k-1)
else:
    right=(n-1-num_1)//(k-1)+1
ans=left+right
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def process_smaller_index(K, min_index):
    if min_index == 0:
        return 0
    else:
        return math.ceil(min_index / K)

def process_larger_index(last_index, K, min_index):
    if min_index == last_index:
        return 0
    else:
        return math.ceil((last_index - min_index) / K)

N, K = map(int, input().split())
A = list(map(int, input().split()))
min_index = A.index(1)
print(process_smaller_index(K - 1, min_index) + process_larger_index(N - 1, K - 1, min_index))

Submission status: Wrong Answer

Solution code:
import math

def process_smaller_index(K, min_index):
    if min_index == 0:
        return 0
    else:
        return math.ceil(min_index / K)

def process_larger_index(last_index, K, min_index):
    if min_index == last_index:
        return 0
    else:
        return math.ceil((last_index - min_index) / K)

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
min_index = A.index(1)
print(process_smaller_index(K - 1, min_index) + process_larger_index(len(A)-1, K - 1, min_index))

Submission status: Wrong Answer

Solution code:
def process_smaller_index(A, K, min_index, count):
    if min_index == 0:
        return count
    end_index = min_index
    while True:
        start_index = max(0, min_index - (K - 1))
        count += 1
        if start_index == 0:
            return count
        end_index = start_index

def process_larger_index(A, K, min_index, count):
    if min_index == len(A) - 1:
        return count
    start_index = min_index
    while True:
        end_index = min(len(A)-1, start_index + (K - 1))
        count += 1
        if end_index == len(A) - 1:
            return count
        start_index = end_index

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
min_index = A.index(1)
count = process_smaller_index(A, K, min_index, 0)
print(process_larger_index(A, K, min_index, count))

Submission status: Wrong Answer

Solution code:
def process_smaller_index(A, K, min_index, count):
    if min_index == 0:
        return count
    end_index = min_index
    while True:
        start_index = max(0, min_index - (K - 1))
        A[start_index:end_index] = [A[min_index]] * (end_index - start_index)
        count += 1
        if start_index == 0:
            return count
        end_index = start_index

def process_larger_index(A, K, min_index, count):
    if min_index == len(A) - 1:
        return count
    start_index = min_index
    while True:
        end_index = min(len(A)-1, start_index + (K - 1))
        A[start_index:end_index] = [A[min_index]] * (end_index - start_index)
        count += 1
        if end_index == len(A) - 1:
            return count
        start_index = end_index

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
min_index = A.index(min(A))
count = process_smaller_index(A, K, min_index, 0)
print(process_larger_index(A, K, min_index, count))

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

print(N // 2)

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:
import math

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

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

print(answer)

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:
# ABC101 C - Minimization
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
r = ceil((N - (A.index(1)+1)) / (K-1))
l = ceil(A.index(1) / (K-1))
print(l+r)

Submission status: Wrong Answer

Solution code:
# ABC101 C - Minimization
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = ceil((N - (A.index(1)+1)) / (K-1))
r = ceil(A.index(1) / (K-1))
print(l+r)

Submission status: Wrong Answer

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

if N == K:
    y = 0
else:
    minA = min(A)
    count_minA = sum([x == minA for x in A])

    n_target = N - count_minA
    n_1 = n_target // (K - 1)
    n_2 = n_target % (K - 1)
    y = n_1 + n_2
print(y)

Submission status: Wrong Answer

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

minA = min(A)
count_minA = sum([x == minA for x in A])

n_target = N - count_minA
n_1 = n_target // (K - 1)
n_2 = n_target % (K - 1)
y = n_1 + n_2
print(y)