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:
# https://atcoder.jp/contests/abc101/tasks/arc099_a
# C - Minimization
import math
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

min_x = min(a_list)
min_x_i_list = [i for i, a in enumerate(a_list) if a == min_x]

c = 0
# 最初のi
start_x_i = min_x_i_list[0]
c += math.ceil((start_x_i) / (K - 1))

index = start_x_i
while index < N - 1:  # 10 ** 5
    # index < j <= index + Kの範囲にmin_xがいるか
    next_min_list = [y for y in min_x_i_list if (index < y) and y <= (index + K)]
    if next_min_list:
        index += K
        c += 1
    else:
        index += K - 1
        c += 1

print(c)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a
# C - Minimization
import math
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

min_x = min(a_list)
min_x_i_list = [i for i, a in enumerate(a_list) if a == min_x]

c = 0
# 最初のi
start_x_i = min_x_i_list[0]
c += math.ceil((start_x_i) / (K - 1))

index = start_x_i
while index < N - 1:  # 10 ** 5
    # index < j <= index + Kの範囲にmin_xがいるか
    next_min_list = [y for y in min_x_i_list if (index < y) and (index + K)]
    if next_min_list:
        next_index = next_min_list[-1]
        index = next_index
        c += 1
    else:
        index += K - 1
        c += 1

print(c)

Submission status: Wrong Answer

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

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

if (N-K)%2 == 0:
    print(1+((N-K)//2))
else:
    print(1+((N-K)//2)+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()))
idx=a.index(1)
if idx==0:
  if (n-1)%(k-1)!=0: 
    print(((n-1)//(k-1))+1)
  else:
    print((n-1)//(k-1))
if idx==n-1:
  if (n-1)%(k-1)!=0: 
    print(((n-1)//(k-1))+1)
  else:
    print((n-1)//(k-1))
else:
  if (n-idx-1)%(k-1)!=0 and idx%(k-1)!=0:
    print(((n-idx-1)//(k-1))+(idx//(k-1))+2)
  if (n-idx-1)%(k-1)==0 and idx%(k-1)==0:
    print(((n-idx-1)//(k-1))+(idx//(k-1)))
  else:
    print(((n-idx-1)//(k-1))+(idx//(k-1))+1)

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(((n-1)//(k-1))+(1 if (n-1)%(k-1)!=0 else 0))
if idx==n-1:
  print(((n-1)//(k-1))+(1 if (n-1)%(k-1)!=0 else 0))
else:
  print((n-idx-1)//(k-1)+(1 if (n-idx-1)%(k-1)!=0 else 0)+(idx)//(k-1)+(1 if (idx)%(k-1)!=0 else 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

nl = (ix - 1) // (k - 1) + 1
nr = (n - ix - 2) // (k - 1) + 1
print(nl + nr)

Submission status: Wrong Answer

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

N,K = II()
A = III()

for i in range(N):
    if A[i]==1:
        p = i
        break

print(math.ceil(p/(K-1)) + math.ceil((N-p-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.floor((N-1)/(K-1)))

Submission status: Wrong Answer

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

import math

id_1 = a.index(1)

if n == k:
  print(1)
elif id_1 >= k - 1 and n - id_1 - 1 >= k - 1:
  print( math.ceil(id_1 / (k - 1)) + math.ceil((n - id_1 - 1) / (k - 1)) )
else:
  print( 1 + math.ceil((n - k) / (k - 1)) )

Submission status: Wrong Answer

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

import math

id_1 = a.index(1)

if n == k:
  print(1)
elif id_1 > k - 1 and n - id_1 - 1 > k - 1:
  print( math.ceil(id_1 / (k - 1)) + math.ceil((n - id_1 - 1) / (k - 1)) )
else:
  print( 1 + math.floor((n - k) / (k - 1)) )

Submission status: Wrong Answer

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

import math

id_1 = a.index(1)

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

pos = a.index(1)
print((pos + 1) // (k - 1) + (n - pos) // (k - 1))

Submission status: Wrong Answer

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

print((n//k)+(n%k))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n

m = min(a)
for i in range(n):
    if a[i] == m:
        b[i] = m

cntsub = 0
cnt = 0
# print(b)
for i in b:
    if i == 0:
        cntsub += 1
    else:
        cnt += math.ceil(cntsub / (k - 1))
        cntsub=0

if cntsub != 0:
    cnt += math.ceil(cntsub / (k - 1))
print(cnt)

Submission status: Wrong Answer

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

def solve(N: int, K: int, A: "List[int]"):
    ix = A.index(1)

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

    ans = min(math.ceil(len(A[:max(0,ix-1)])/(K-1))+math.ceil(len(A[min(ix+2,len(A)):])/(K-1))+1,
            math.ceil(len(A[:max(0,ix)])/(K-1))+math.ceil(len(A[min(ix+1,len(A)):])/(K-1)))
    print(ans)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def solve(N: int, K: int, A: "List[int]"):
    ix = A.index(1)

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

    ans = math.ceil(len(A[:max(0,ix-1)])/(K-1))+math.ceil(len(A[min(ix+2,len(A)):])/(K-1))+1
    print(ans)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def solve(N: int, K: int, A: "List[int]"):
    ix = A.index(1)

    print(math.ceil(len(A[:ix])/(K-1))+math.ceil(len(A[ix+1:])/(K-1)))

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
N, K = [int(s) for s in input().split()]
print(2 + (N-K)//(K-1)) if N-K>0 else print(1)

Submission status: Wrong Answer

Solution code:
N, K = [int(s) for s in input().split()]
print(2 + (N-K)//(K-1))

Submission status: Wrong Answer

Solution code:
import math
def solve():
  n,k = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  place = a.index(1)
  tmall = math.ceil(n/(k-1))
  if n == k:
    tmall = 1
    
  zenhan = math.ceil(place/(k-1))
  kouhan = math.ceil((n-place-1)/(k-1))
  print(min(zenhan + kouhan,tmall))
solve()

Submission status: Wrong Answer

Solution code:
import math
def solve():
  n,k = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  place = a.index(1)
  tmall = math.ceil(n/(k-1))
  zenhan = math.ceil(place/(k-1))
  kouhan = math.ceil((n-place-1)/(k-1))
  print(min(zenhan + kouhan,tmall))
solve()

Submission status: Wrong Answer

Solution code:
import math
def solve():
  n,k = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  place = a.index(1)
  zenhan = math.ceil(place/(k-1))
  kouhan = math.ceil((n-place-1)/(k-1))
  print(zenhan + kouhan)
solve()

Submission status: Wrong Answer

Solution code:
import math
def solve():
  n,k = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  place = a.index(1)
  zenhan = math.ceil(place/(k-1))
  kouhan = math.ceil((n-place)/(k-1))
  print(zenhan + kouhan)
solve()

Submission status: Wrong Answer

Solution code:
import math
def solve():
  n,k = (int(i) for i in input().split())
  ct = math.ceil(n/k)
  print(ct)
solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
a=list(map(int, input().split()))
a_m=a.index(1)
if len(a[:a_m])%(k-1) == 0 and len(a[(a_m)+1:])%(k-1) == 0:
    print(len(a[:a_m])//(k-1) + len(a[(a_m)+1:])//(k-1))
else:
    print(len(a[:a_m])//(k-1) + len(a[(a_m)+1:])//(k-1) + 1)

Submission status: Wrong Answer

Solution code:
n,k=map(int, input().split())
a=list(map(int, input().split()))
a_m=a.index(min(a))
if len(a[:a_m])%(k-1) == 0 and len(a[(a_m)+1:])%(k-1) == 0:
    print(len(a[:a_m])//(k-1) + len(a[(a_m)+1:])//(k-1))
elif len(a[:a_m])%(k-1) != 0 and len(a[(a_m)+1:])%(k-1) != 0:
    print(len(a[:a_m])//(k-1) + len(a[(a_m)+1:])//(k-1) + 2)
else:
    print(len(a[:a_m])//(k-1) + len(a[(a_m)+1:])//(k-1) + 1)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

ind = A.index(1)

L = len(A[:ind])
R = len(A[ind+1:])

ans = 1000000

ans = min(ans, 1 + ceil((L-K+1)/(K-1)) + ceil(R/(K-1)))
ans = min(ans, 1 + ceil(L/(K-1)) + ceil((R-K+1)/(K-1)))
ans = min(ans, 1 + ceil((L-K+2)/(K-1)) + ceil((R-K+2)/(K-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()]
if n == k:
    print(1)
elif n == 2:
    print(n-1)
else:
    print((n-1)//(k-1) + 1)

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
one = n
for i in range(n):
    if a[i] == 1:
        one = i
        break
if n == k:
    print(1)
else:
    l = one
    r = n-one-1
    if l < k:
        while l < k-1 and r > 0:
            l += 1
            r -= 1
    elif r < k:
        while r < k-1 and l > 0:
            r += 1
            l -= 1
    print(math.ceil(l/(k-1)) + math.ceil(r/(k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A = [int(_) for _ in input().split()]

m = min(A)
# idx = A.index(m)
i = 0
ans = 0
while i < N:
    if A[i] == m:
        i += 1
        continue
    ans += 1
    i += K - 1
print(ans)

Submission status: Wrong Answer

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

index_one = a.index(1)

left_num = index_one
right_num = n - index_one - 1

ans = -(-left_num // (k - 1)) -(-right_num // (k - 1))

print(ans)

Submission status: Wrong Answer

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

index = A.index(1)

before_num = index
after_num = N - index - 1

ope = 0
if N == K:
    ope = 1
elif K > before_num or K > after_num:
    div, mod = divmod(N, K - 1)
    if mod == 0:
        ope = div
    else:
        ope = div + 1
elif K % 2:
    before_num -= (K - 1) // 2
    after_num -= (K - 1) // 2
    ope += before_num // (K - 1)
    ope += after_num // (K - 1)
else:
    ope1 = 0
    ope2 = 0
    before_num = index - (K - 2) // 2
    after_num = N - index - 1 - K // 2
    div, mod = divmod(before_num, K - 1)
    if mod == 0:
        ope1 += div
    else:
        ope1 += div + 1
    div, mod = divmod(after_num, K - 1)
    if mod == 0:
        ope1 += div
    else:
        ope1 += div + 1
        before_num = index - K // 2
        after_num = N - index - 1 - (K - 2) // 2
    div, mod = divmod(before_num, K - 1)
    if mod == 0:
        ope2 += div
    else:
        ope2 += div + 1
    div, mod = divmod(after_num, K - 1)
    if mod == 0:
        ope2 += div
    else:
        ope2 += div + 1
    if ope1 < ope2:
        ope = ope1
    else:
        ope = ope2
    ope += 1

print(ope)

Submission status: Wrong Answer

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

index = A.index(1)
print(index)

before_num = index
after_num = N - index - 1

ope = 0
if N == K:
    ope = 1
elif K > before_num or K > after_num:
    div, mod = divmod(N, K - 1)
    if mod == 0:
        ope = div
    else:
        ope = div + 1
elif K % 2:
    before_num -= (K - 1) // 2
    after_num -= (K - 1) // 2
    ope += before_num // (K - 1)
    ope += after_num // (K - 1)
else:
    ope1 = 0
    ope2 = 0
    before_num = index - (K - 2) // 2
    after_num = N - index - 1 - K // 2
    div, mod = divmod(before_num, K - 1)
    if mod == 0:
        ope1 += div
    else:
        ope1 += div + 1
    div, mod = divmod(after_num, K - 1)
    if mod == 0:
        ope1 += div
    else:
        ope1 += div + 1
        before_num = index - K // 2
        after_num = N - index - 1 - (K - 2) // 2
    div, mod = divmod(before_num, K - 1)
    if mod == 0:
        ope2 += div
    else:
        ope2 += div + 1
    div, mod = divmod(after_num, K - 1)
    if mod == 0:
        ope2 += div
    else:
        ope2 += div + 1
    print(ope1, ope2)
    if ope1 < ope2:
        ope = ope1
    else:
        ope = ope2
    ope += 1

print(ope)

Submission status: Wrong Answer

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

print(N, K, len(A))

index = A.index(1)
print(index)

before_num = index
after_num = N - index - 1

ope = 0
if N == K:
    ope = 1
elif K > before_num or K > after_num:
    div, mod = divmod(N, K - 1)
    if mod == 0:
        ope = div
    else:
        ope = div + 1
elif K % 2:
    before_num -= (K - 1) // 2
    after_num -= (K - 1) // 2
    ope += before_num // (K - 1)
    ope += after_num // (K - 1)
else:
    ope1 = 0
    ope2 = 0
    before_num = index - (K - 2) // 2
    after_num = N - index - 1 - K // 2
    div, mod = divmod(before_num, K - 1)
    if mod == 0:
        ope1 += div
    else:
        ope1 += div + 1
    div, mod = divmod(after_num, K - 1)
    if mod == 0:
        ope1 += div
    else:
        ope1 += div + 1
        before_num = index - K // 2
        after_num = N - index - 1 - (K - 2) // 2
    div, mod = divmod(before_num, K - 1)
    if mod == 0:
        ope2 += div
    else:
        ope2 += div + 1
    div, mod = divmod(after_num, K - 1)
    if mod == 0:
        ope2 += div
    else:
        ope2 += div + 1
    print(ope1, ope2)
    if ope1 < ope2:
        ope = ope1
    else:
        ope = ope2
    ope += 1

print(ope)

Submission status: Wrong Answer

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

index = A.index(1)

before_num = index
after_num = N - index - 1

ope = 0
if N == K:
    ope = 1
elif K > before_num or K > after_num:
    div, mod = divmod(N, K - 1)
    if mod == 0:
        ope = div
    else:
        ope = div + 1
elif K % 2:
    before_num -= (K - 1) // 2
    after_num -= (K - 1) // 2
    ope += before_num // (K - 1)
    ope += after_num // (K - 1)
else:
    ope1 = 0
    ope2 = 0
    before_num -= (K - 2) // 2
    after_num -= K // 2
    ope1 += before_num // (K - 1)
    ope1 += after_num // (K - 1)
    before_num -= K // 2
    after_num -= (K - 2) // 2
    ope2 += before_num // (K - 1)
    ope2 += after_num // (K - 1)
    if ope1 < ope2:
        ope = ope1
    else:
        ope = ope2

print(ope)

Submission status: Wrong Answer

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

index = A.index(1)

before_num = index
after_num = N - index - 1

ope = 0
if K > before_num or K > after_num:
    ope = N // (K - 1)
elif K % 2:
    before_num -= (K - 1) // 2
    after_num -= (K - 1) // 2
    ope += before_num // (K - 1)
    ope += after_num // (K - 1)
else:
    ope1 = 0
    ope2 = 0
    before_num -= (K - 2) // 2
    after_num -= K // 2
    ope1 += before_num // (K - 1)
    ope1 += after_num // (K - 1)
    before_num -= K // 2
    after_num -= (K - 2) // 2
    ope2 += before_num // (K - 1)
    ope2 += after_num // (K - 1)
    if ope1 < ope2:
        ope = ope1
    else:
        ope = ope2

print(ope)

Submission status: Wrong Answer

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

idx = 0

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

if n <= k:
    print(1)
    exit()
    
ans = (n-idx+k-2)//(k-1) + (idx+k-2)//(k-1)

for i in range(k-1):
    ans = min(ans,  (n-idx+k-2-1-i)//(k-1) + (idx+k-2-(k-2-i))//(k-1) + 1)
print(ans)

Submission status: Wrong Answer

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

idx = 0

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

if n <= k:
    print(1)
    exit()
    
ans = (n-idx+k-2)//(k-1) + (idx+k-2)//(k-1)

for i in range(k-2):
    ans = min(ans,  (n-idx+k-2-1-i)//(k-1) + (idx+k-2-(k-2-i))//(k-1) + 1)
print(ans)

Submission status: Wrong Answer

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

idx = 0

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

if n <= k:
    print(1)
    exit()
    
ans = (n-idx+k-2)//(k-1) + (idx+k-2)//(k-1)

for i in range(k):
    ans = min(ans,  (n-idx+k-2-1-i)//(k-1) + (idx+k-2-(k-2-i))//(k-1) + 1)
print(ans)

Submission status: Wrong Answer

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

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

exit()

idx = 0

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

if n <= k:
    print(1)
    exit()
    
ans = (n-idx+1)//(k-1) + (idx+1)//(k-1)

for i in range(k):
    ans = min(ans,  (n-idx+1-1-i)//(k-1) + (idx+1-(k-2-i))//(k-1) + 1)
print(ans)

Submission status: Wrong Answer

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

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

exit()

idx = 0

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

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

print(min( (n-idx+1)//(k-1) + (idx+1)//(k-1) , (n-idx+1-1)//(k-1) + (idx+1-1)//(k-1) + 1))

Submission status: Wrong Answer

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

idx = 0

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

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

print(min( (n-idx+1)//(k-1) + (idx+1)//(k-1) , (n-idx+1-1)//(k-1) + (idx+1-1)//(k-1) + 1))

Submission status: Wrong Answer

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

idx = 0

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

if n <= 3:
    print(1)
    exit()

print(min( (n-idx+1)//2 + (idx+1)//2 , (n-idx+1-1)//2 + (idx+1-1)//2 + 1))

Submission status: Wrong Answer

Solution code:
import math

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

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

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

Submission status: Wrong Answer

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

minIndex = 0
for i, a in enumerate(A) :
    if a < A[minIndex] :
        minIndex = i

def ceil(x, y) :
    return (x + y - 1) // y

ans = ceil(minIndex, K - 1) + ceil(N - minIndex - 1, K - 1)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

i = l.index(1)
if n == k:
    print(1)
elif i+1<k or n-i<k:
    print(math.ceil((n-k)/(k-1))+1)
else:
    print(math.ceil(i/(k-1)) + math.ceil((n-i-1)/(k-1)))

Submission status: Wrong Answer

Solution code:
import math

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

i = l.index(1)

if i+1<k or n-i<k:
    print(math.ceil((n-k)/(k-1))+1)
else:
    print(math.ceil(i/(k-1)) + math.ceil((n-i-1)/(k-1)))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, A: "List[int]"):
    min_idx = [i for i, e in enumerate(A) if e == 1][0] + 1
    left_p = max(min_idx-K, 0)//(K-1)
    right_p = math.ceil(max(N-min_idx+1-K, 0)/(K-1))
    if min_idx in [1, N]:
        e = 1
    else:
        e = 2
    print(left_p + right_p + e)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, A: "List[int]"):
    min_idx = [i for e, i in enumerate(A) if e == 1][0] + 1
    left_p = min_idx//(K-1)
    right_p = (N-min_idx+1)//(K-1)
    print(left_p + right_p)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, A: "List[int]"):
    min_idx = [i for e, i in enumerate(A) if e == 1][0]
    print(math.ceil((min_idx+1)//(K-1))+math.ceil((N-min_idx)//(K-1)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(N: int, K: int, A: "List[int]"):
    min_idx = [i for e, i in enumerate(A) if e == min(A)][0]
    print(math.ceil((min_idx+1)//(K-1))+math.ceil((N-min_idx)//(K-1)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(n):
    if lst[i] == 1:
        start = i

l = start #1より左側の数字数
r = n - start -1 #１より右側の数字数

if k==1:
  print(n)
elif n==k:
  print(1)
else:
    if l == 0: #numl : 左側領域の試行回数
        numl = 0
    elif l <= k-1:
        numl = 1
    elif l % (k-1) == 0:
        numl = l // (k-1)
    else:
        numl = (l // (k-1)) + 1
    
    if r == 0: #numr : 右側領域の試行回数
        numr = 0
    elif r <= k-1:
        numr = 1
    elif r % (k-1) == 0:
        numr = r // (k-1)
    else:
        numr = (r // (k-1)) + 1
    
    print(numl + numr)

Submission status: Wrong Answer

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

for i in range(n):
    if lst[i] == 1:
        start = i

l = start #1より左側の数字数
r = n - start -1 #１より右側の数字数

if k==1:
    print(n)

else:
    if l == 0: #numl : 左側領域の試行回数
        numl = 0
    elif l <= k-1:
        numl = 1
    elif l % (k-1) == 0:
        numl = l // (k-1)
    else:
        numl = (l // (k-1)) + 1
    
    if r == 0: #numr : 右側領域の試行回数
        numr = 0
    elif r <= k-1:
        numr = 1
    elif r % (k-1) == 0:
        numr = r // (k-1)
    else:
        numr = (r // (k-1)) + 1
    
    print(numl + numr)

Submission status: Wrong Answer

Solution code:

n,k = map(int,input().split())
lst = [int(i) for i in input().split()]

for i in range(n):
    if lst[i] == 1:
        start = i

l = start
r = n - start -1

if l == 0:
    numl = 0
elif l <= k-1:
    numl = 1
elif l % (k-1) == 0:
    numl = l // (k-1)
else:
    numl = (l // (k-1)) + 1

if r == 0:
    numr = 0
elif r <= k-1:
    numr = 1
elif r % (k-1) == 0:
    numr = r // (k-1)
else:
    numr = (r // (k-1)) + 1

print(numl + numr)