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

if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数

    if l < K-1 or r < K-1:
        if l < r:
            r -= K-l-1
            l = 0
        else:
            l -= K-r-1
            r = 0
        ans += 1
    ans += math.ceil(l / (K-1))
    ans += math.ceil(r / (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 = 0

if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数

    # if l < K or r < K:
    #     if l < r:
    #         r -= K-l-1
    #         l = 0
    #     else:
    #         l -= K-r-1
    #         r = 0
    #     ans += 1
    ans += math.ceil(l / (K-1))
    ans += math.ceil(r / (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 = 0

if N == K:
    print(1)
    quit()
else:
    one_index = A.index(1)
    l = one_index #1の左側にある数字の数
    r = N - one_index - 1 #1の右側にある数字の数

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

Submission status: Wrong Answer

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

resolve()

Submission status: Wrong Answer

Solution code:
def main():
    from math import ceil
    n, k, *a = map(int, open(0).read().split())
    i = a.index(1)
    if i in [0, n - 2]:
        ans = 1 + ceil((n - k) / (k - 2))
    else:
        k -= 1
        l, r = max(0, i - 1), max(0, n - i - 2)
        ans = 1 + ceil(l / k) + ceil(r / k)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(n):
    if a[i] == 1:
        ind_1 = i
        break

a_mae = len(a[:ind_1])
a_ato = len(a[ind_1+1:])

print(-(-a_mae//(k-1))-(-a_ato//(k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_min = min(A)
index = A.index(A_min)
ans = 0
left = index
right = N - 1 - index
if left % (K - 1) == 1:
    right -= 1
elif right % (K - 1) == 1:
    left -= 1
ans += math.ceil(left / (K - 1))
ans += math.ceil(right / (K - 1))   
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_min = min(A)
cnt = 0
now = 0
for i in range(N):
    if A[i] == A_min:
        if now == 0:
            cnt += math.ceil((i - now) / 2)
            now = i
        else:
            cnt += math.ceil((i - now - 1) / 2)
            now = i
        if (i - now) % 2 == 1:
                now += 1
cnt += math.ceil((N - 1 - now) / 2)
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
A_min = min(A)
cnt = 0
now = 0
for i in range(N):
    if A[i] == A_min:
        if now == 0:
            cnt += math.ceil((i - now) / 2)
            now = i
        else:
            cnt += math.ceil((i - now - 1) / 2)
cnt += math.ceil((N - 1 - now) / 2)
print(cnt)

Submission status: Wrong Answer

Solution code:
n , k = map(int,input().split())
l = list(map(int,input().split()))
m = l.index(min(l))
if k <= m:
    ans = (m + 1) //k + 1 + (n -m) // k +1
if k > m:
    o = k - m 
    ans = (k - o) // k + 1

Submission status: Wrong Answer

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

if len(a) == k:
  print(1)
  exit()

print(((len(a)-1) //( k -1)) + 1)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    if a[i] == 1:
        check = i
        break
left = check
right = n - check -1
ans = left//(k-1) + right//(k-1)
if left%(k-1) != 0:
    ans += 1
if right%(k-1) != 0:
    ans += 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)


print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

if alist[0] == 1 or alist[-1] == 1:
    print(math.ceil((n-1)//(k-1)))
    sys.exit()

for i in range(n):
    if alist[i] == 1:
        mini=i
        sho=i
        dai=n-i-1
        break

shomod=sho%(k-1)
daimod=dai%(k-1)

if shomod+daimod==0:
  print(sho//(k-1)+dai//(k-1))
  sys.exit()

if shomod + daimod <= k-1 :
    print(sho//(k-1) + dai//(k-1)+1)
else:
    print(sho//(k-1) + dai//(k-1)+2)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

if alist[0] == 1 or alist[-1] == 1:
    print(math.ceil((n-1)//(k-1)))
    sys.exit()

for i in range(n):
    if alist[i] == 1:
        mini=i
        sho=i
        dai=n-i-1
        break

shomod=sho%(k-1)
daimod=dai%(k-1)

if shomod + daimod <= k-1 :
    print(sho//(k-1) + dai//(k-1)+1)
else:
    print(sho//(k-1) + dai//(k-1)+2)

Submission status: Wrong Answer

Solution code:
import math

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

answer = math.ceil(N / (K - 1))

print(answer)

Submission status: Wrong Answer

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

answer = N / (K - 1)

print(answer)

Submission status: Wrong Answer

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

count = 1
if n > k:
    for i in range(k - 1, n, k - 1):
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
li = list(map(int,input().split()))

a = li.index(1) #1より前にある数
b = x-1-a #1より後にある数

if a%(y-1) == 0 and b%(y-1) == 0:
    print(a//(y-1)+b//(y-1))
elif a%(y-1) == 0 or b%(y-1) == 0:
    print(a//(y-1)+b//(y-1)+1)
else:
    print(a//(y-1)+b//(y-1)+2)

Submission status: Wrong Answer

Solution code:
x, y = map(int,input().split())
li = list(map(int,input().split()))
a = li.index(1)
b = x-a+1
if x == y:
    print(1)
else:
    print(a//(y-1)+b//(y-1))

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = map(int, input().split())
A = list(map(int, input().split()))
a = np.argmin(A)
if a != 0 and a < k-1:
  ans_1 = 1
  a = k-1
else:
  ans_1 = (a)//(k-1)
  a = ans_1*(k-1)
if n-a-1 != 0 and n-a < k-1:
  ans_2 =  1
else:
  ans_2 = (n-a)//(k-1)
print(ans_1 + ans_2)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = map(int, input().split())
A = list(map(int, input().split()))
a = np.argmin(A)
if a != 0 and a < k-1:
  ans_1 = 1
else:
  ans_1 = (a)//(k-1)
if n-a-1 != 0 and n-a < k-1:
  ans_2 =  1
else:
  ans_2 = (n-a)//(k-1)
print(ans_1 + ans_2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def main():
    N, K = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    mi = A.index(1)
    ans = math.ceil(mi / (K-1)) + math.ceil((N-mi-1) / (K-1))
    print(ans)


if __name__ == '__main__':
    main()

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=[int(i) for i in input().split()]
print(int(n/(k-1)))

Submission status: Wrong Answer

Solution code:
n,k=list(map(int, input().split()))
a= list(map(int, input().split()))
final=min(a)
ans=0
flag=-1
check=0
for v in a:
    if flag==-1 and v!=final:
        flag=2
        ans+=1
        check=0
    elif flag>=0:
        if check==0 and v==final:
            flag-=1
            check=1
        flag+=1
        if flag==k:
            flag=-1
print(ans)

Submission status: Wrong Answer

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

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

n_l = (left + k - 2) // (k - 1)
n_r = (right + k - 2) // (k - 1)

print(n_l + n_r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

i = 0
cnt = 0
while True:
    if N == K:
        cnt += 1
        #print(1)
        break
    ans = A[i*2:i*2+K]
    if not ans:
        break
    i+=1
    #print(ans)
    cnt +=1
print(cnt)

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-i-1)/(K-1)))

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
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0
#print(m1, m2)
ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1
if N <= K:
    ans = 1
if K == 2:
    ans = 0
    ans += a - 1
    ans += N - 1 - cnt
print(ans)

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
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0
print(m1, m2)
ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1
if N <= K:
    ans = 1
if K == 2:
    ans = 0
    ans += a - 1
    ans += N - 1 - cnt
print(ans)

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
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0

ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1
if N <= K:
    ans = 1
print(ans)

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
        break

a = cnt + 1
b = N - 1 - i + 1
#print(a, b)
m1 = a // (K - 1)
n1 = a % (K - 1)

m2 = b // (K - 1)
n2 = b % (K - 1)
ans = 0

ans += m1 + m2
if n1 > 1:
    ans += 1
if n2 > 1:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()

K -= 1
i = A.index(1)

# 怒りの全探索
ans = 0
for j in range(0, N, K):
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()

K -= 1
i = A.index(1)
# # コーナーケース対策
# if i < K and i >= (N - K):
#     print(2)
#     exit()
# elif i < K:
#     i = K
# elif i >= (N - K):
#     i = N - K - 1
# right = (i - 1) // K + 1
# left = (N - 1 - i - 1) // K + 1
right = i // K + (i % K > 0)
left = len(A[i + 1:]) // K + (len(A[i + 1:]) % K > 0)

print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# # コーナーケース対策
# if i < K and i >= (N - K):
#     print(2)
#     exit()
# elif i < K:
#     i = K
# elif i >= (N - K):
#     i = N - K - 1
right = (i - 1) // K + 1
left = (N - 1 - i) // K
# right = i // K + (i % K > 0)
# left = (N - 1 - i) // K + ((N - i - 1) % K > 0)

# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# # コーナーケース対策
# if i < K and i >= (N - K):
#     print(2)
#     exit()
# elif i < K:
#     i = K
# elif i >= (N - K):
#     i = N - K - 1
right = (i - 1) // K + 1
left = (N - 1 - i - 1) // K + 1
# right = i // K + (i % K > 0)
# left = (N - 1 - i) // K + ((N - i - 1) % K > 0)

# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# # コーナーケース対策
# if i < K and i >= (N - K):
#     print(2)
#     exit()
# elif i < K:
#     i = K
# elif i >= (N - K):
#     i = N - K - 1
right = (i - 1) // K + 1 if i != 0 else 0
left = (N - 1 - i - 1) // K + 1 if i != N - 1 else 0
# right = i // K + (i % K > 0)
# left = (N - 1 - i) // K + ((N - i - 1) % K > 0)

# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# # コーナーケース対策
# if i < K and i >= (N - K):
#     print(2)
#     exit()
# elif i < K:
#     i = K
# elif i >= (N - K):
#     i = N - K - 1
# right = (i - 1) // K + 1 if i != 0 else 0
# left = (N - 1 - i - 1) // K + 1 if i != N - 1 else 0
right = i // K + (i % K > 0)
left = (N - 1 - i) // K + ((N - i - 1) % K > 0)

# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# コーナーケース対策
if i < K and i >= (N - K):
    print(2)
    exit()
elif i < K:
    i = K
elif i >= (N - K):
    i = N - K - 1
right = (i - 1) // K + 1
left = (N - 1 - i - 1) // K + 1


# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# コーナーケース対策
if i < K:
    i = K
elif i >= (N - K):
    i = N - K - 1
right = (i - 1) // K + 1
left = (N - 1 - i - 1) // K + 1


# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# コーナーケース対策
if i <= K:
    i = K
elif i >= (N - K):
    i = N - K - 1
right = (i - 1) // K + 1
left = (N - 1 - i - 1) // K + 1


# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
if N == K:
    print(1)
    exit()
A = read_ints()
K -= 1
i = A.index(1)
# コーナーケース対策
if i <= K:
    i = K + 1
elif i >= (N - K):
    i = N - K - 1
right = (i - 1) // K + 1
left = (N - 1 - i - 1) // K + 1


# print(right, left)
print(right + left)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a


import sys
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
A = read_ints()
K -= 1
i = A.index(1)
right = (i - 1) // K + 1
left = (N - 1 - i - 1) // K + 1

# コーナーケース対策
print(right + left if N != K else 1)

Submission status: Wrong Answer

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

min_ind = a_ls.index(min(a_ls))
left_len = min_ind
right_len = n - min_ind - 1
if left_len < k or right_len < k:
    ans = 1
    ans += -(-(n - k)//2)
else:
    one_stroke = k - 1
    left_num = -(-left_len // one_stroke)
    right_num = -(-right_len // one_stroke)
    ans = left_num + right_num
if n == k:
    ans = 1

print(ans)

Submission status: Wrong Answer

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

min_ind = a_ls.index(min(a_ls))
left_len = min_ind
right_len = n - min_ind - 1
one_stroke = k - 1
left_num = -(-left_len // one_stroke)
right_num = -(-right_len // one_stroke)
ans = left_num + right_num
if n == k:
    ans = 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = 0
for i in range(n):
  if a[i] == 1:
    m = i
    break
print(math.ceil(i/(k-1))+math.ceil((n-i)/(k-1)))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
m = 0
for i in range(n):
  if a[i] == 1:
    m = i
    break
print(math.ceil((i-1)/(k-1))+math.ceil((n-i)/(k-1)))

Submission status: Wrong Answer

Solution code:
import math
N,M = list(map(int,input().split()))
n_l = "".join(input().split())
A = n_l.find("1")
before = math.ceil(A / (M-1))
after = math.ceil((N-A-1) / (M-1))
print(before+after)

Submission status: Wrong Answer

Solution code:
from math import ceil
import sys

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

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

idx = A.index(1)

ans = ceil((N - idx) / 2)
ans += idx // 2

print(ans)

Submission status: Wrong Answer

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

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

cnt = 1
length = K
while True:
    if length >= N:
        print(cnt)
        break
    length += K-1 
    cnt += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i, a in enumerate(map(int, input().split())):
  if a == 1:
    index = i
    break

print(2 + (index - 1) // (k - 1) + (n - index - 2) // (k - 1))

Submission status: Wrong Answer

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

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

aleft = alist[:alist.index(1)]
aright = alist[alist.index(1)+1:]

ans = math.ceil(len(aleft)/(k-1)) + math.ceil(len(aright)/(k-1))
print(ans)

Submission status: Wrong Answer

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

min_num=min(A)
count=K-1

print(int(-(-len(A)/count)))

Submission status: Wrong Answer

Solution code:
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n,k = readInts()
    A = readInts()

    Alen = len(A)
    nokori = Alen - k
    print(1 + nokori // (k-1) + nokori % (k-1))




if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
n=input().rstrip().split()
preans=int(n[0])/int(n[1])

ans=int(preans)
if int(n[0])%int(n[1])!=0:
  ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=input().rstrip().split()
preans=int(n[0])/int(n[1])
ans=int(preans)+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)
if(ind%(K-1)==0):
    print(ind//(K-1) + (len(A)-ind-1)//2 + int(bool(((len(A)-ind-1)%(K-1)))))
else:
    print((len(A)-ind-1)//2 + int(bool(((len(A)-ind-1)%(K-1)))) + (ind)//2 + int(bool(((ind)%(K-1)))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

idx = A.index(1)
d = k-1
if idx == 0 or idx == n-1:
  ans = (n - 1 + d - 1) // d
elif idx <= k-1 or n-k <= idx:
  ans = 1 + (n - k + d - 1) // d
else:
  ans = (idx + d - 1) // d + (n - idx - 1 + d - 1) // d

print(ans)

Submission status: Wrong Answer

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

p = A.index(1)
if p == 0 or p == n-1:
  ans = (n + k - 2) // k
elif p < k-1 or n-k < p:
  ans = 1 + (n-1) // k
else:
  ans = (p + k - 1) // k + (n - p + k) // k

print(ans)

Submission status: Wrong Answer

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

p = A.index(1)
if p == 0 or p == n-1:
  ans = n // 2
elif p == 1 or p == n-2:
  ans = 1 + (n-2) // 2
else:
  ans = (p + 1) // 2 + (n - p + 1) // 2

print(ans)

Submission status: Wrong Answer

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

part = []
ln = 0
for a in A:
  if a == 1:
    if ln > 0:
      part.append(ln)
      ln = 0
  else:
    ln += 1
else:
  if ln > 0: part.append(ln)

ans = 0
for p in part:
  ans += (p + 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

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

ind1 = A.index(1)
nleft = ind1/(K-1)
nright = (len(A)-ind1-1)/(K-1)
if nleft.is_integer():
    nleft = int(nleft)
else:
    nleft = int(nleft+1)
if nright.is_integer():
    nright = int(nright)
else:
    nright = int(nright+1)

print(nleft+nright)

Submission status: Wrong Answer

Solution code:

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from functools import reduce

from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import statistics
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm(a, b):
  return a*b//gcd(a, b)

def main():
  N, K = map(int, readline().split())
  A = list(map(int, readline().split()))
  print((N-1)//(K-1))
  
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def resolve():
    N, K = list(map(int, input().split(" ")))
    A = list(map(int, input().split(" ")))
    i = A.index(1)
    import math
    print(math.ceil(len(A[:i])/(K-1)) + math.ceil(len(A[i+1:])/(K-1)))

if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

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

print(N//(K-1))

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
N, K = map(int, input().split())    
A = list(map(int, input().split()))
#print(N, K, A)

print(N//(K-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
Alist = list(map(int,input().split()))
n = 0
for i in range(N):
    if Alist[i] == 1:
        p = i
n = n -(-p//(K-1))
n = n -(-(N-p-1)//(K-1))
print(n)

Submission status: Wrong Answer

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

one = 0
for i in range(n):
    if a[i] == 1:
        one = i + 1
        break
    
front = -(-(one - 1) // (k - 1))
back = -(-(n - one) // (k - 1))
#print(front, back)
print(front + back)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
a = LI()
for i in range(n):
    if a[i] == 1:
        idx = i
        break
ans = (idx-1) // (k-1) + (n-2-idx) // (k-1) + 2
print(ans)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
z=a.index(1)
L= -(-z//(k-1))
R=-(-(n-z-1)//(k-1))
if z%(k-1)+(n-z-1)%(k-1)>=k:
    print(L+R-1)
else:
    print(L+R)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def Minimization(n , k , al):

    ans = -(-n // k)

    return ans

def main():
    n , k = map(int , input().split())
    al = list(map(int , input().split()))
    print(Minimization(n , k , al))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

num = lst.index(1)

if k-1<=num and k-1<=n-num-1:
    print(math.ceil(num/(k-1))+math.ceil((n-num-1)/(k-1)))
else:
    print(math.ceil(n/k))

Submission status: Wrong Answer

Solution code:
import math

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

num = lst.index(1)

if k-1<=num and k-1<=n-num:
    print(math.ceil(num/(k-1))+math.ceil((n-num-1)/(k-1)))
else:
    print(math.ceil(n/k))

Submission status: Wrong Answer

Solution code:
import math

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

num = lst.index(1)
print(math.ceil(num/(k-1))+math.ceil((n-num-1)/(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)
elif k == 2:
    print(n-1)
else:
    print(n // (k-1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a_min = min(A)

pos = 0
ans = 0

for pos in range(N):
    if A[pos] != a_min:
        for i in range(pos, min(pos+K-1, N)):
            A[i] = a_min
        ans += 1

print(ans)