Problem:


Score : 300 points

Problem Statement

There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.

On this sequence, Snuke can perform the following operation:

Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.

Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.

Constraints

2 \leq K \leq N \leq 100000

A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

Print the minimum number of operations required.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

One optimal strategy is as follows:

In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.

In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4



Sample input:
4 3
2 3 1 4


Sample output:
2

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
num_array = [int(i) for i in input().split()]
min_num_index=num_array.index(1)
array_length=len(num_array)
print(math.ceil(min_num_index/(float(K)-1)) + math.ceil((array_length-1-min_num_index)/(float(K)-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1)+1) <= K-1:
    print(math.floor(ind/(K-1)) + math.floor((N-ind-1)/(K-1))+1)
else:
    print(math.floor(ind/(K-1)) + math.floor((N-ind-1)/(K-1))+2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

left = A.index(1)
right = N-left-1
K -= 1

print(min(math.ceil(left/K)+math.ceil(right/K), math.ceil((left-1)/K)+math.ceil((right-1)/K)+1))

Submission status: Wrong Answer

Solution code:
import math

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

right = A.index(1)

left = N - right - 1

r = math.ceil(right/K)
l = math.ceil(left/K)
print(r+l)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3


# x x x x x x
# -----
#     -----
def main(N, K):
    cnt = 0
    while N >= 0:
        cnt += 1
        N -= K
        if N <= 0:
            break
        N += 1
    return cnt

#print(main(4, 3))
#print(main(4, 4))
#print(main(8, 3))

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if n <= k:
  print(1)
elif k == 2:
  print(int(n-1))
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 = [int(elem) for elem in input().split()]
a_lst = input().split()

if n <= k:
  print(1)
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 = [int(elem) for elem in input().split()]
a_lst = input().split()

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

Submission status: Wrong Answer

Solution code:
import math
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

min_place = a.index(1) + 1
left = math.ceil((min_place - 1) / (k-1)) 
if left != 0:
  left_lest = (k-1) - (min_place - 1) % (k-1)
else:
  left_lest = 0
right = math.ceil((n - min_place - left_lest) / (k-1))

print(left + right)

Submission status: Wrong Answer

Solution code:
import math
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

min_place = a.index(1) + 1
left = math.ceil((min_place - 1) / (k-1)) 
left_lest = (k-1) - (min_place - 1) % (k-1)
right = math.ceil((n - min_place - left_lest) / (k-1))

print(left + right)

Submission status: Wrong Answer

Solution code:
import math
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

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

Submission status: Wrong Answer

Solution code:
m = input().split()
m1 = int(m[0])
m2 = int(m[1])
ans = m1 // m2
rest = m1 % m2
rest = ans + rest

while(rest > m2):
  ans = ans + 1
  rest = (ans + rest) % m2 
  
if rest == ans:
  print(ans+(ans // m2))
else:
  print(ans+1)

Submission status: Wrong Answer

Solution code:
m = input().split()
m1 = int(m[0])
m2 = int(m[1])
ans = m1 // m2
rest = m1 % m2
rest = ans + rest

while(rest > m2):
  ans = ans + 1
  rest = (ans + rest) % m2 
  
if rest == ans:
  print(ans)
else:
  print(ans+1)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
N = a[0]
K = a[1]
A = list(map(int,input().split()))
#1の左側と右側
#A[i]=1のとき, 左側のi個の数字を1に変え、右側のN-i-1個の数字を1に変える
#1回の操作でK-1個の数字を1に変えられる
#左側はi // (K-1) + 0or1回の操作で完了右側も同様
one = 1000000
for i in range(N):
    if A[i] == 1:
        one = i
        break

cnt = 0
if one % (K-1) == 0:
    cnt += one // (K-1)
else:
    cnt += one // (K-1) + 1

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

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))
N = a[0]
K = a[1]
A = list(map(int,input().split()))
#1の左側と右側
#A[i]=1のとき, 左側のi個の数字を1に変え、右側のN-i-1個の数字を1に変える
#1回の操作でK-1個の数字を1に変えられる
#左側はi // (K-1) + 0or1回の操作で完了右側も同様
one = 0
for i in range(N):
    if A[i] == 1:
        one = i
        break

cnt = 0
if one % (K-1) == 0:
    cnt += one // (K-1)
else:
    cnt += one // (K-1) + 1

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

Submission status: Wrong Answer

Solution code:

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

m=(N[0]-1-(N[0]-1)%(N[1]-1))/(N[1]-1)+1
print(int(m))

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)
if n == k:
    print(1)
else:
    minus_len = len(a[:idx])
    plus_len = len(a[idx+1:])
    m = math.ceil(minus_len / (k-1))
    p = math.ceil(plus_len / (k-1))
    ans = int(m + p)
    print(ans)

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:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    if A[i]==1:
        num=i
round=1
left=num
right=N-num-1
#print(left)
#print(round)
#print(right)
r=0
l=0
count=0
count_r=0
count_l=0
while right>r:
    r+=K-1
    count_r+=1
while left>l:
    l+=K-1
    count_l+=1
#print("r",count_r)
#print("l",count_l)
count=count_r+count_l
print(count)

Submission status: Wrong Answer

Solution code:
from math import ceil

n,k = map(int,input().split())
A = list(map(int,input().split()))
u = A.index(1)
print(ceil(u/(k-1))+ceil((n-1-u)/(k-1)))

Submission status: Wrong Answer

Solution code:
from math import ceil

n,k = map(int,input().split())
A = list(map(int,input().split()))
u = A.index(1)
print(ceil(u/(k-1))+ceil((n-u)/(k-1)))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A=list(map(int,input().split()))
flag=False
for i in range(K):
  if N%(K-i)==0:
    print(int(N/(K-i)))
    flag=True
    break
if flag==False:
  print(int(N/(K-1))+1)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A=list(map(int,input().split()))
for i in range(K):
  if N%(K-i)==0:
    print(int(N/(K-i)))
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int, input().split())
A = input().split()
A = [int(i) for i in A]
if N/K > 1:
    if(N-3)%(K-1) == 0:
        print(1 + (N-3)//(K-1) )
    else:
        print(1 + (N-3)//(K-1) + 1)
else:
    print(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:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

if N == K:
    print(1)
    exit()
result = 0
N -= K
result += 1
result += N / (K-1)
if N % (K-1) != 0:
    result = int(result)

print(int(result))

Submission status: Wrong Answer

Solution code:
#  import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
#  sys.setrecursionlimit(10**7)
#  inf = 10 ** 20
#  eps = 1.0 / 10**10
#  mod = 10**9+7
#  dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
#  ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
#  def LI(): return [int(x) for x in sys.stdin.readline().split()]
#  def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
#  def F(): return float(sys.stdin.readline())
#  def S(): return input()
#  def pf(s): return print(s, flush=True)

#  N, K = LI()
#  A = LI()

#  if N == K:
#      print(1)
#      exit()
#  N -= K
#  result = N / (K-1) + 1
#  if result % 1 != 0:
#      result //= 1
#      result += 1

#  print(int(result))



import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

if N == K:
    print(1)
    exit()
result = 0
N -= K
result += 1
result += N / (K-1)
if N % (K-1) != 0:
    result = int(result)

print(result)

Submission status: Wrong Answer

Solution code:
#  import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
#  sys.setrecursionlimit(10**7)
#  inf = 10 ** 20
#  eps = 1.0 / 10**10
#  mod = 10**9+7
#  dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
#  ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
#  def LI(): return [int(x) for x in sys.stdin.readline().split()]
#  def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
#  def F(): return float(sys.stdin.readline())
#  def S(): return input()
#  def pf(s): return print(s, flush=True)

#  N, K = LI()
#  A = LI()

#  if N == K:
#      print(1)
#      exit()
#  N -= K
#  result = N / (K-1) + 1
#  if result % 1 != 0:
#      result //= 1
#      result += 1

#  print(int(result))



import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

if N == K:
    print(1)
    exit()
result = 0
N -= K
result += 1
result += N / (K-1)
if N % (K-1) != 0:
    result = int(result) + 1

print(result)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

if N == K:
    print(1)
    exit()
result = 0
N -= K
result += 1
result += N / (K-1)
if N % (K-1) != 0:
    result = round(result) + 1

print(result)

Submission status: Wrong Answer

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

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

print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 101 C Minimization
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K))
    A = getIntList()
    d.dmp(A)
    if K == 2:
        overlap = 0
    else:
        overlap = 1
    count = 1 + (N-K+overlap)//(K-1)
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 101 C Minimization
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K))
    A = getIntList()
    d.dmp(A)
    count = 1 + (N-K+1)//(K-1)
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Wrong Answer

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

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

p = -1
for i in range(n):
    if a[i] == 1:
        p = i

if p%(k-1) == 0:
    res = p//(k-1)
else:
    res = p//(k-1)+1

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
print(N//(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()]

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(n // k)

Submission status: Wrong Answer

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

def op(n, k):
    ans = 1 if n % (k - 1) > 0 else 0
    return n // (k - 1) + ans

i = A.index(1)
left = i
right = N - (i + 1)

if N == K:
    ans = 1
elif left <= K - 2 or right <= K - 2:
    ans = 1 + op(N - K, K)
else:
    ans = op(left, K) + op(right, K)
print(ans)

Submission status: Wrong Answer

Solution code:
N , K  = map(int, input().split())
lst = list(input().split())
count = 0
idx = lst.index("1")
lst1 = lst[:idx]
lst2 = lst[idx + 1:]
if len(lst1) > 0:
    count += len(lst1) // (K-1)
    if len(lst1) % (K-1) != 0:
        count +=  +1        
if len(lst2) > 0:
    count += len(lst2) // (K-1)
    if len(lst2) % (K-1) != 0:
        count +=  +1        
        
print(count)

Submission status: Wrong Answer

Solution code:
N , K  = map(int, input().split())
lst = list(input().split())
count = 0
idx = lst.index("1")
lst1 = lst[:idx]
lst2 = lst[idx + 1:]
if len(lst1) > 0:
    if len(lst1) % (K-1) == 0:
        count += len(lst1) // (K-1)
    else :
        count += len(lst1) // (K-1) +1
if len(lst2) > 0:
    if len(lst2) % (K-1) == 0:
        count += len(lst2) // (K-1)
    else :
        count += len(lst2) // (K-1) +1    
        
print(count)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    if 3 + 2 * i >= n:
        break
print(i+1)

Submission status: Wrong Answer

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

p1 = A.index(1)

if 0 <= p1 <= K-1 or N-K <= p1 <= N-1:
    ans = N//(K-1)
else:
    ans = (N - p1)//(K - 1) + (p1 + 1)//(K - 1)

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N, K = map(int, input().split())
a = [int(x) for x in stdin.readline().rstrip().split()]
mind = a.index(min(a))
ans = 0


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
lst = list(map(int, input().split()))
a = lst.index(1)
print(math.ceil(a/2) + math.ceil((n-a-1)/2))

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split(" "))
A = input().split(" ")
A = [int(i) for i in A]
c = 0
d = A.index(1)
#print(d)
if K >= N:
    print(1)
else:
    R = 0
    L = 0
    if (d+1) - K <= 0:
        L += 1
    else:
        L += math.ceil((d+1)/(K-1))
    DIF = len(A)-1 - d
    if DIF - K <= 0:
        R += 1
    else:
        R += math.ceil(DIF/(K-1))
    print(R+L)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split(" "))
A = input().split(" ")
A = [int(i) for i in A]
c = 0
d = A.index(1)
#print(d)
if K >= N:
    print(1)
else:
    R = 0
    L = 0
    if (d+1) - K <= 0:
        L += 1
    else:
        L += (d+1)/(K-1)
    
    print(R+L)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split(" "))
A = input().split(" ")
A = [int(i) for i in A]
c = 0
if K >= N:
    print(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:
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()))
print((n-1)//(k-1))

Submission status: Wrong Answer

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

i = a.index(1)
print((n-1-i)//(k-1) + i//(k-1) + bool((n-1-i)%(k-1)) + bool(i%(k-1)))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
nums = list(map(int,input().split()))
indexnum = nums.index(min(nums))
if len(nums)<K:
    print(1)
else:
    print((len(nums[:indexnum])//(K-1)+len(nums[indexnum:])//(K-1)))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
nums = list(map(int,input().split()))
indexnum = nums.index(min(nums))
if len(nums)<=K:
    print(1)
else:
    print((len(nums[:indexnum])//(K-1)+len(nums[indexnum:])//(K-1)))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
nums = list(map(int,input().split()))
if len(nums)<=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()))
if(N == K):
  print(1)
else:
  print(N//(K-1))

Submission status: Wrong Answer

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

i = A_list.index(1)
left = len(A_list[:i])
right = N - left - 1

if N == K:
    print(1)
elif left == 0 or right == 0:
    if N % (K - 1) == 0:
        print(N // (K - 1))
    else:
        print(N // (K - 1) + 1)
elif left % (K - 1) + right % (K - 1) + 1 <= K:
    print(left // (K - 1) + right // (K - 1) + 1)
else:
    print(left // (K - 1) + right // (K - 1) + 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
ind = A.index(1)
left = ind + 1
cnt = 0
res = 0
if left > 1:
    left -= K
    cnt += 1
    if left > 0:
        cnt += math.ceil(left / (K - 1))
        res = left % (K - 1)
right = N - ind - res
if right > 0:
    right -= K
    cnt += 1
    if right > 0:
        cnt += math.ceil(right / (K - 1))
print(cnt)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(len(a)):
    if a[i]==1:
        p=i+1
        break
ans=0
ans+=p//(k-1)+1
right=n-(i+1)-(k-11%(k-1))
ans+=-(-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()))
ind = A.index(1)
left = ind + 1
cnt = 0
res = 0
if left > 1:
    left -= K
    cnt += 1
    if left > 0:
        cnt += math.ceil(left / (K - 1))
        res = math.ceil(left / (K - 1)) - left // (K - 1)
right = N - ind - res
if right > 0:
    right -= K
    cnt += 1
    if right > 0:
        cnt += math.ceil(right / (K - 1))
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n <= k:
    print(1)
    exit()
res = 0
# 1の範囲を増やしていくという方向性？
range_left = array.index(1)
range_right = n - range_left -1
# 一度に変更できるのはk-1個(1を含めないといけないため)
k -= 1
if range_left == 0:
    res += ceil(range_right/k)
    print(res)
    exit()
elif range_right == 0:
    res += ceil(range_left/k)
    print(res)
    exit()

if range_left <= k:
    res += 1
    range_right -= (k - range_left)
    res += ceil(range_right / k)
else:
    res += ceil(range_left / k)
    range_right -= range_left%k
    res += ceil(range_right / k)
print(res)