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 = list(map(int, input().split()))
A = [int(a) for a in input().split()]
print((N - 1 + K - 2) / (K - 1))

Submission status: Wrong Answer

Solution code:
import math as m

N, K = list(map(int, input().split()))
A = [int(a) for a in input().split()]
pos_1 = A.index(1)
print(m.ceil((N - 1 - pos_1) / (K - 1)) + m.ceil((pos_1) / (K - 1)))

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
A = [int(a) for a in input().split()]
dis_K = K - 1
pos_1 = A.index(1)
ans = 0
head = pos_1
while head < N:
    ans += 1
    head += dis_K
behind = pos_1
while behind >=dis_K:
    ans += 1
    behind -= dis_K
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
list_a = list(map(int, input().split()))
p = list_a.index(1)
t_left = math.ceil(p / (k-1))
t_right = math.ceil((len(list_a) - (p+1)) / (k-1))
print(t_left + t_right)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, K = map(int, input().split())
A = input()
S = (N // (K-1))
if S <= 0:
    print(1)
else:
    print(S)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
A = list(map(int, input().split()))
x = 0
ma = min(A)
for i in range(N):
  if A[i] == ma:
    x = i
    break
print(-(-i // (K - 1)) + -(-(N - i - 1) // (K - 1)))

Submission status: Wrong Answer

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

q, mod = divmod(int(n), int(k) - 1)


if q == 1 and mod == 1:
  print(1)
elif mod == 0:
  print(q)
else:
  print(q + 1)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

# MIN = min(A)
idx = A.index(min(A))
L = A[:idx]
R = A[idx+1:]

ans = ceil(len(L) / (K - 1)) + ceil(len(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()))
if N <= K:
    print(1)
elif N-1 == K and (A.index(min(A)) == 0 or A.index(min(A)) == N-1):
    print(1)
else:   
    ind = A.index(min(A))
    before = ind
    after = N-ind-1
    count = math.ceil(before/(K-1)) + math.ceil(after/(K-1))
    print(count)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N <= K or A.index(min(A)) == 0 or A.index(min(A)) == N-1:
    print(1)
else:   
    ind = A.index(min(A))
    before = ind
    after = N-ind-1
    count = math.ceil(before/(K-1)) + math.ceil(after/(K-1))
    print(count)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
if N <= K:
    print(1)
else:   
    ind = A.index(min(A))
    before = ind
    after = N-ind-1
    count = math.ceil(before/(K-1)) + math.ceil(after/(K-1))
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
index=a.index(m)
if K>=N:
  print(1)
else:
  if (m+1)-K>=0 and N-m>=K:
    if (m+1)%(K-1)==0:
      ans=(m+1)//(K-1)
      if (N-m)%(K-1)==0:
        ans+=(N-m)//(K-1)
      else:
        ans+=((N-m)//(K-1)+1)
    else:
      ans=(m+1)//(K-1)+1
      if (N-m)%(K-1)==0:
        ans+=(N-m)//(K-1)
      else:
        ans+=((N-m)//(K-1)+1)
  else:
    if N%(K-1)==0:
      ans=(N//(K-1))
    else:
      ans=(N//(K-1)+1)
  print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
index=a.index(m)
if K>=N:
  print(1)
else:
  if (m+1)-K>=0:
    if (m+1)%(K-1)==0:
      ans=(m+1)//(K-1)
      if (N-m)%(K-1)==0:
        ans+=(N-m)//(K-1)
      else:
        ans+=((N-m)//(K-1)+1)
    else:
      ans=(m+1)//(K-1)+1
      if (N-m)%(K-1)==0:
        ans+=(N-m)//(K-1)
      else:
        ans+=((N-m)//(K-1)+1)
  else:
    if N%(K-1)==0:
      ans=(N//(K-1))
    else:
      ans=(N//(K-1)+1)
  print(ans)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
m=min(a)
index=a.index(m)
if K>=N:
  print(1)
else:
  if (m+1)-K>0:
    if (m+1)%(K-1)==0:
      ans=(m+1)//(K-1)
      if (N-m)%(K-1)==0:
        ans+=(N-m)//(K-1)
      else:
        ans+=((N-m)//(K-1)+1)
    else:
      ans=(m+1)//(K-1)+1
      if (N-m)%(K-1)==0:
        ans+=(N-m)//(K-1)
      else:
        ans+=((N-m)//(K-1)+1)
  else:
    if N%(K-1)==0:
      ans=(N//(K-1))
    else:
      ans=(N//(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()))
if (N - 1) % (K - 1) == 0:
    print((N - 1) // (K - 1))
else:
    i = A.index(1) + 1
    cnt = 0
    cnt += math.ceil((i - 1) // (K - 1)) + math.ceil((N - i + 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()))
i = A.index(1) + 1
cnt = 0
cnt += math.ceil((i - 1) // (K - 1)) + math.ceil((N - i + 1) // (K - 1))
print(cnt)

Submission status: Wrong Answer

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

p = al.index(1)
print(math.ceil(p / 2) + math.ceil((n-p-1) / 2))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
min = 0
x = a.index(1) +1
if n==k:
  print(1)
elif (n-k)//(k-1)==0:
  print(2 + (n-k)//(k-1))
else:
  print(1 + (n-k)//(k-1))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
min = 0
x = a.index(1) +1
if n==k:
  print(1)
elif (n-k)//(k-1)==0:
  print(1 + (n-k)//(k-1))
else:
  print(2 + (n-k)//(k-1))

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
min = 0
x = a.index(1) +1
if n==k:
  print(1)
else:
  print(2 + (n-k)//(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:
    ans=0
    cnt=0
    for i in range(1,n):
        cnt+=(k-1)
        if cnt>=n:
            ans=i
            break
    print(ans)

Submission status: Wrong Answer

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

print (n // (k-1))

Submission status: Wrong Answer

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

ai = 0
for i,x in enumerate(a):
  if x==1:
    ai = i+1
    break
ans = 0
if ai <= k or n-k <= ai:
  ans = (n-k)//(k-1) + math.ceil((n-k)/(k-1) - (n-k)//(k-1))
else:
  ans = (ai-k)//(k-1) + math.ceil((ai-k)/(k-1) - (ai-k)//(k-1))
  ans += (n-ai)//(k-1) + math.ceil((n-ai)/(k-1) - (n-ai)//(k-1))

print(ans+1)

Submission status: Wrong Answer

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

ai = 0
for i,x in enumerate(a):
  if x==1:
    ai = i+1
    break
ans = 0
if ai <= k or n-k <= ai:
  ans = math.ceil((n-k)/(k-1))
else:
  ans = math.ceil((ai-k)/(k-1)) + math.ceil((n-ai)/(k-1))
  
print(ans+1)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
position = A.index(1)
left = position
right = len(A) - position - 1
counter = 0
width = k - 1

import math
counter += left // width
if left % width != 0:
  counter += 1
  right -= left % width
if right > 0:
  counter += math.ceil(right / width)
print(right, counter)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = list(map(int, input().split()))
position = A.index(1)
left = position
right = len(A) - position - 1
counter = 0
width = k - 1

import math
counter += left // width
if left % width != 0:
  counter += 1
  right -= left % width
if right > 0:
  counter += math.ceil(right / width)
print(counter)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
index1 = Alist.index(1)
left_num = index1
right_num = N - index1 - 1

ans = 0
del_per_step = K - 1
if left_num == 0:
    pass
elif left_num % del_per_step == 0:
    ans += left_num // del_per_step
else:
    ans += left_num // del_per_step + 1

if right_num == 0:
    pass
elif right_num % del_per_step == 0:
    ans += right_num // del_per_step
else:
    ans += right_num // del_per_step + 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np

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

# 最小値を見つけて、そこから何回の操作で全部最小値にできるか
# 最小値の場所をxとすると、math.ceil(x/k-1) + math.ceil(n-x/k-1)

#最小値の位置
x = np.argmin(a)

ans = math.ceil(x/(k-1)) + math.ceil((n-1-x)/(k-1))

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n,k = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))

point = 1

point += (n-k+1)//(k-1)

print(point)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import ceil
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    i=A.index(1)
    print(ceil(i/(k-1))+ceil((n-i-1)/(k-1)))
resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from math import ceil
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    i=A.index(1)
    print(ceil(i/2)+ceil((n-i-1)/2))
resolve()

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
a = list(map(int,input().split()))
imin = a.index(min(a))
left = imin//(K-1)+1
if (imin%(K-1)==0):
    left-=1
right = (N-imin)//(K-1)+1
if ((N-imin)%(K-1)==0):
    right-=1
print(left+right)

Submission status: Wrong Answer

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

A_len = len(A)
A_len -= K
if A_len <= 0:
    print(1)
else:
    print(A_len // (K-1) + 2)

Submission status: Wrong Answer

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

print(len(A) // (K-1))

Submission status: Wrong Answer

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

min_A = min(A)

A.append(min_A)
A_goodlen = 0
for i in range(N):
    if A[i] != min_A:
        A_goodlen += 1
    else:
        if A[i+1] == min_A:
            pass
        else:
            A_goodlen += 1

print(A_goodlen // (K-1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-08 13:38:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, k, *a = (int(x) for x in sys.stdin.read().split())
    i = a.index(1)
    l = k - 1
    left, right = i, (n - 1) - i
    if left % l == 0:
        if right % l == 0:
            ans = left // l + right // l
        else:
            ans = left // l + right // l + 1
    else:
        if right % l  == 0:
            ans = left // l + 1 + right // l 
        else:
            if left % l + right % l >= l:
                ans = left // l + right // l + 2
            else:
                ans = left // l + right // l + 1 
    
    print(ans)




if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Wrong Answer

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-08 13:38:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, k, *a = (int(x) for x in sys.stdin.read().split())
    i = a.index(1)
    l = k - 1
    left, right = i, (n - 1) - i
    if left % l == 0:
        if right % l == 0:
            ans = left // l + right // l
        else:
            ans = left // l + right // l + 1
    else:
        ans = left // l + right // l + 1
    
    print(ans)




if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Wrong Answer

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-08 13:38:56(JST)
## internal modules
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n, k, *a = (int(x) for x in sys.stdin.read().split())
    i = a.index(1)
    left, right = i, (n - 1) - i
    if left % 2 == 0:
        if right % 2 == 0:
            ans = left // 2 + right // 2
        else:
            ans = left // 2 + right // 2 + 1
    else:
        ans = left // 2 + right // 2 + 1
    
    print(ans)




if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Wrong Answer

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

import numpy as np
min_idx = np.argmin(A)
ans = 0
if min_idx % (K-1):
    ans += min_idx //(K-1) + 1
else:
    ans += min_idx//(K-1)

if (len(A)-min_idx-1) %(K-1):
    ans += (len(A)-min_idx-1)//(K-1) + 1
else:
    ans += (len(A)-min_idx-1)//(K-1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
ind = A.index(1)
ans = (ind+K-2)//(K-1)+(N-1-ind+K-2)//(K-1)
if ind%(K-1)+(N-1-ind)%(K-1) >= K and K >= 3:
    ans -= 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)
ans = (ind+K-2)//(K-1)+(N-1-ind+K-2)//(K-1)
if ind%(K-1)+(N-1-ind)%(K-1) >= K-1 and K >= 3:
    ans -= 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)
ans = (ind+K-2)//(K-1)+(N-1-ind+K-2)//(K-1)
if ind%(K-1)+(N-1-ind)%(K-1) > K-1:
    ans -= 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)
ans = (ind+K-2)//(K-1)+(N-1-ind+K-2)//(K-1)
if ind%(K-1)+(N-1-ind)%(K-1) >= K-1:
    ans -= 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)
ans = (ind+K-2)//(K-1)+(N-1-ind+K-2)//(K-1)
if (ind+K-2)%(K-1)+(N-1-ind+K-2)%(K-1) <=  K-1:
    ans -= 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)
print((ind+K-2)//(K-1)+(N-ind+K-3)//(K-1))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
m = min(A)
ans = 0
i = 0
while i < N:
    if A[i] == m:
        i += 1
    else:
        ans += 1
        i += K - 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
a = inpl()
ind = a.index(1)
print(-(-ind//(k-1)) + -(-(n-ind-1)//(k-1)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import statistics

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

min_i = A.index(1)
answer = (min_i+1-1 + K-2) // (K-1) + (N-min_i-1 + K-2) // (K-1)
if K == N:
  answer = 1
print(answer)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
ind=l.index(1)
left=ind
right=n-ind-1 
from math import ceil 
print(ceil(left/(k-1))+ceil(right/(k-1)))

Submission status: Wrong Answer

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

list = [i-1 for i, v in enumerate(A) if v == max(A)]
list.insert(0, 0)
list.append(N)

total = 0

for i in range(len(list)-1):
  if (list[i+1] - list[i]) % (K - 1) == 0:
    total = total + (list[i+1] - list[i]) // (K - 1)
  else:
  	total = total + (list[i+1] - list[i]) // (K - 1) + 1
    
print(total)

Submission status: Wrong Answer

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

list = [i-1 for i, v in enumerate(A) if v == max(A)]
list.insert(0, 0)
list.append(N)

print(list)
total = 0

for i in range(len(list)-1):
  if (list[i+1] - list[i]) % (K - 1) == 0:
    total = total + (list[i+1] - list[i]) // (K - 1)
  else:
  	total = total + (list[i+1] - list[i]) // (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:

if __name__ == '__main__':

	n,m = input().split()

	ans = int(n) // int(m)
	md = int(n) % int(m)

	print(ans+md)

Submission status: Wrong Answer

Solution code:
import math

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

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

min_ele = min(A)

ans = math.floor(n/(k-1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

min_ele = min(A)

idx = A.index(min_ele)

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

Submission status: Wrong Answer

Solution code:
from math import ceil

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

minA = min(A)
idxl = 0
ans = 0
while minA in A[idxl:]:
  idx_min = A[idxl:].index(minA)
  ans += 0 if idx_min == 0 else 1 + ceil((1+idx_min-K)/(K-1))
  idxl = idx_min + idxl + 1
  #print(ans, idx_min, idxl)

ans += 0 if idx_min == N else 1 + max(0,ceil((N-idx_min-K)/(K-1)))
#print(idx_min,N, max(0,ceil((N-idx_min-K)/(K-1))))
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

N,K = map(int,input().split())
A = list(map(int,input().split()))
idx_min = A.index(min(A)) + 1
l = 0 if idx_min == 1 else 1 + ceil((idx_min-K)/(K-1))
r = 0 if idx_min == N else 1 + ceil((N+1-idx_min-K)/(K-1))
print(l+r)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans=(i+(K-2))//(K-1)+((N-1)-i+(K-2))//(K-1)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

idx = S.index(1)

if idx // k == 0 and idx < k:
    idx = k
elif (n-idx-1) // k == 0 and (n-idx-1) % k:
    idx = n-k-1

l = idx//k
if idx % k:
    l += 1
r = (n-idx-1)//k
# print(n-1-idx,k)
if (n-idx-1) % k:
    r += 1
# print(l,r)
print(l+r)

Submission status: Wrong Answer

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

idx = S.index(1)
l = idx//k
if idx % k:
    l += 1
r = (n-1-idx)//k
# print(n-1-idx,k)
if (n-1-idx) % k:
    r += 1
# print(l,r)
print(l+r)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

#idx = a.index(min(a))
#print(n // k + 1 )
ans = None
if n == k:
    ans = 1
else:
    if (n - 1) % 2 == 1:
        ans = (n - 1) // (k - 1) + 1
    else:
        ans = (n - 1) // (k - 1)
print(ans)

Submission status: Wrong Answer

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

#idx = a.index(min(a))
#print(n // k + 1 )
ans = None
if n == k:
    ans = 1
else:
    if (n - 1) % 2 == 1:
        ans = (n - 1) // (k - 1) + 1
    else:
        ans = (n - 1) // (k - 1)
    print(ans)

Submission status: Wrong Answer

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

#idx = a.index(min(a))
#print(n // k + 1 )
ans = None
if n == k:
    ans = 1
else:
    ans = (n - 1) // (k - 1) + 1
print(ans)

Submission status: Wrong Answer

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

#idx = a.index(min(a))
#print(n // k + 1 )
ans = (n - 1) // (k - 1) + 1
print(ans)

Submission status: Wrong Answer

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

#idx = a.index(min(a))
print(n // k + 1 )

Submission status: Wrong Answer

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

left=one-1
right=N-one

print(-(-left//(K-1))-(-right//(K-1)))

Submission status: Wrong Answer

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

def function(n,k,a):
    ind1 = a.index(1)
    pre = len(a[:ind1])
    ex = len(a[ind1:])    
    ans = -(-pre//(k-1)) + -(-ex//(k-1))
    if n == k:
        ans = 1
    return int(ans)

print(function(n,k,a))

Submission status: Wrong Answer

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

ind1 = a.index(1)

pre = len(a[:ind1])
ex = len(a[ind1:])

ans = -(-pre/(k-1)) + -(-ex/(k-1))

print(int(ans))

Submission status: Wrong Answer

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

k2 = k-1
a2 = n-1
ans =0
if a2%k2==0:
    print(1)
elif n<=2:
    print(1)
else:
    ans += a2//k2
    ans +=1
    print(ans)

Submission status: Wrong Answer

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

k2 = k-1
a2 = n-1
ans =0
if a2%k2==0 and n==k:
    print(1)
else:
    ans += a2//k2
    ans +=1
    print(ans)

Submission status: Wrong Answer

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

k2 = k-1
a2 = n-1
ans =0
if n==3 and k == 3:
    print(1)
else:
    ans += a2//k2
    ans +=1
    print(ans)

Submission status: Wrong Answer

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

k2 = k-1
a2 = n-1
ans =0
if a2%k2==0:
    print(1)
else:
    ans += a2//k2
    ans +=1
    print(ans)

Submission status: Wrong Answer

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

k = sum(a)
if k%n==0:
    print(1)
else:
    print(k%n)

Submission status: Wrong Answer

Solution code:
[N, K] = map(int, input().split())
A = input()
print(1 if N == K else N // (K - 1) + (1 if N - (N//(K - 1))*(K - 1) > 1 else 0))

Submission status: Wrong Answer

Solution code:
[N, K] = map(int, input().split())
A = input()
print(N // (K - 1) + (1 if N - (N//(K - 1))*(K - 1) > 1 else 0))

Submission status: Wrong Answer

Solution code:
[N, K] = map(int, input().split())
A = list(map(int, input().split()))
print(N // (K - 1) + (1 if N - (N//(K - 1))*K > 1 else 0))

Submission status: Wrong Answer

Solution code:
[N, K] = map(int, input().split())
A = list(map(int, input().split()))
print(N // (K - 1) + (1 if N - (N//(K - 1))*K > 0 else 0))

Submission status: Wrong Answer

Solution code:
[N, K] = map(int, input().split())
A = input()
count = 1
while N != 1:
	N = N // K + (1 if N  - N*(N // K) != 0 else 0)
	count = count + 1
print((K**(count - 1) - 1)//(K - 1))

Submission status: Wrong Answer

Solution code:
'''
1を見つけて，そこから左右に伸ばしていく
'''

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

ind1 = a.index(1)

pre = len(a[:ind1])
ex = len(a[ind1:])

ans = pre//(k-1) + ex//(k-1) 

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# i = A.index(1)

# if i <= N - 1 or N - i <= K:
#     ans = N // (K - 1)
# else:
#     ans = (N // (K - 1)) + 1

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

Submission status: Wrong Answer

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

# i = A.index(1)

# if i <= N - 1 or N - i <= K:
#     ans = N // (K - 1)
# else:
#     ans = (N // (K - 1)) + 1

print(N // (K - 1))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
point = 0
for i in range(n):
    if a[i]==1:
        point=i+1
x = (-point+1)//(k-1)
x = -x
y = -n+point
y = y//(k-1)
y = -y
print(x+y)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
from math import floor
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

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

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

print(ceil(n / k))

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil
index_min = lambda l: min(enumerate(l), key=lambda x:x[1])
inputs = sys.stdin.readlines()

n, k = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

if n == k:
    print(1)
else:
    former = index_min(A)[0]
    latter = n - 1 - former
    ceil(former / (k-1)), ceil(latter / (k-1))
    print(ceil(former / (k-1)) + ceil(latter / (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)
ans = 0
if ind == 0 or ind == N - 1:
    ans = math.ceil((N - 1) / (K -1))
else:
    # 左部分
    ans += math.ceil((ind) / (K - 1))
    # 右部分
    ans += math.ceil((N - ind - 1) / (K - 1))
print(ans)

Submission status: Wrong Answer

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

count+=-(-a//2)
if a==len(A):
    print(count)
    exit()
elif a%2==1:
    a+=1
count+=-(-(len(A)-1-a)//2)
print(count)

Submission status: Wrong Answer

Solution code:
import math

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

# 最終的に全て1になるので、最初の1の場所からなるべく効率的に1を広めればよい
index_1 = A.index(1)

# 中央から進める場合と、1に近い方の端から順に進める場合
if K <= index_1 <= (N-1) - (K-1) -1:
    # 初手、長さKの区間のどこに1がくるか
    tmp = []
    for i in range(K):
        len_rest_left = index_1 - i
        len_rest_right = N - len_rest_left - K
        tmp.append(math.ceil(len_rest_left/(K-1)) + math.ceil(len_rest_right/(K-1)))
    ans = min(tmp)
else:
    ans = math.ceil((N-1)/(K-1))
    
print(ans)