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 = [int(nk) for nk in input().split()]
A = [int(a) for a in input().split()]
if (N-1) % (K-1) == 0:
  print(int(N-1) / (K-1))
else:
  print(int((N-1) // (K-1)) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

if __name__ == "__main__":
    N, K = map(int, input().split())
    numbers = list(map(int, input().split()))
    a = numbers[0:numbers.index(1)]
    b = numbers[numbers.index(1) + 1:]

    print(math.ceil(len(a) / (K - 1)) + math.ceil(len(b) / (K - 1)) - max(0, len(a) % (K - 1) - 1))

Submission status: Wrong Answer

Solution code:
import math

if __name__ == "__main__":
    N, K = map(int, input().split())
    numbers = list(map(int, input().split()))
    a = numbers[0:numbers.index(1)]
    b = numbers[numbers.index(1) + 1:]

    print(math.ceil(len(a) / (K - 1)) + math.ceil(len(b) / (K - 1)))

Submission status: Wrong Answer

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

idx_mn_A = A.index(1)
d_1 = idx_mn_A
d_2 = (len(A)-1) - idx_mn_A
D = [d_1, d_2]
for i in [0, 1]:
  if K > D[i] + 1:
    D[1-i] -= K - (D[i] + 1)

ans = 0
for d in D:
  cnt = 0
  while d > 0:
    d -= K-1
    cnt += 1
  ans += cnt

if N == K:
  ans = 1

print(ans)

Submission status: Wrong Answer

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

idx_mn_A = A.index(1)
d_1 = idx_mn_A
d_2 = (len(A)-1) - idx_mn_A

ans = 0
for d in [d_1, d_2]:
  cnt = 0
  while d > 0:
    d -= K-1
    cnt += 1
  ans += cnt
  
if N == K:
  ans = 1

print(ans)

Submission status: Wrong Answer

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

idx_mn_A = A.index(1)
d_1 = idx_mn_A
d_2 = (len(A)-1) - idx_mn_A

ans = 0
for d in [d_1, d_2]:
  cnt = 0
  while d > 0:
    d -= K-1
    cnt += 1
  ans += cnt
print(ans)

Submission status: Wrong Answer

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

mn_A = min(A)
idx_mn_A = [i for i, x in enumerate(A) if x == mn_A]
d_1 = idx_mn_A[0]
d_2 = (len(A)-1) - idx_mn_A[0]

ans = 0
for d in [d_1, d_2]:
  cnt = 0
  while d > 0:
    d -= K-1
    cnt += 1
  ans += cnt
print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b=LI()
  l=LI()

  return -(-(a-1)//b)

print(main())

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b=LI()
  l=LI()

  mn=min(l)
  mn_i=l.index(mn)

  return -(-mn_i//(b-1))-(-(a-mn_i-1)//(b-1))

print(main())

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

if N == K:
    print(1)
else:
    print(math.ceil(N/(K-1)))

Submission status: Wrong Answer

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

left_num = A.index(1)
right_num = N-left_num-1
print(left_num)
print(right_num)

ans = math.ceil(left_num/(K-1))+math.ceil(right_num/(K-1))
print(ans)

Submission status: Wrong Answer

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

left_num = A.index(1)
right_num = N-left_num-1

ans = math.ceil(left_num/(K-1))+math.ceil(right_num/(K-1))
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, K = map(int, input().split(" "))
	A = list(map(int, input().split(" ")))
	
	if K >= N:
		print(1)
		sys.exit()
		
	K -= 1
	tmp = 0
	if N % K == 0:
		tmp = N // K
	else:
		tmp = N // K
		tmptmp = N - (tmp * K)
		if tmptmp != 1:
			tmp += 1
	
	print(tmp)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, K = map(int, input().split(" "))
	A = list(map(int, input().split(" ")))
	
	if K >= N:
		print(1)
		sys.exit()
		
	K -= 1
	tmp = 0
	if N % K == 0:
		tmp = N // K
	elif N % K == 1:
		tmp = N // K
	else:
		tmp = (N // K) + 1
	
	print(tmp)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, K = map(int, input().split(" "))
	A = list(map(int, input().split(" ")))
	
	if K >= len(A):
		print(1)
		sys.exit()
		
	K -= 1
	tmp = 0
	if N % K == 0:
		tmp = N // K
	else:
		tmp = (N // K) + 1
	
	print(tmp)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N, K = map(int, input().split(" "))
	A = list(map(int, input().split(" ")))
	
	K -= 1
	
	tmp = N // K
	'''
	if N % K == 0:
		tmp = N // K
	else:
		tmp = (N // K) + 1
		'''
	
	print(tmp)
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
place = 0
for i in range(n):
  if a[i] == 1:
    place = i+1

l = (place-1)//(k-1) if (place-1)%(k-1)==0 else (place-1)//(k-1)+1
a = k-1-(place-1)%(k-1)
r = (n-place)//(k-1) if (n-place)%(k-1)==0 else (n-place)//(k-1)+1
a += k-1-(n-place)%(k-1)

if (place-1)%(k-1)+(n-place)%(k-1) < k-1:
  print(l+r)
else:
  print(l+r-a//(k-1))

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
place = 0
for i in range(n):
  if a[i] == 1:
    place = i+1

l = (place-1)//(k-1) if (place-1)%(k-1)==0 else (place-1)//(k-1)+1
a = k-1-(place-1)%(k-1)
r = (n-place)//(k-1) if (n-place)%(k-1)==0 else (n-place)//(k-1)+1
a += k-1-(n-place)%(k-1)

if a < k-1:
  print(l+r)
else:
  print(l+r-a//(k-1))

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
place = 0
for i in range(n):
  if a[i] == 1:
    place = i+1

l = (place-1)//(k-1) if (place-1)%(k-1)==0 else (place-1)//(k-1)+1
a = (place-1)%(k-1)
r = (n-place)//(k-1) if (n-place)%(k-1)==0 else (n-place)//(k-1)+1
a += (n-place)%(k-1)

if a < k-1:
  print(l+r)
else:
  print(l+r-1)

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
place = 0
for i in range(n):
  if a[i] == 1:
    place = i+1

l = (place-1)//(k-1) if (place-1)%(k-1)==0 else (place-1)//(k-1)+1
a = (place-1)%(k-1)
r = (n-place)//(k-1) if (n-place)%(k-1)==0 else (n-place)//(k-1)+1
a += (n-place)%(k-1)

if a < k-1:
  print(l+r)
else:
  print(l+r-a//(k-1))

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
place = 0
for i in range(n):
  if a[i] == 1:
    place = i+1

l = (place-1)//(k-1) if (place-1)%(k-1)==0 else (place-1)//(k-1)+1
r = (n-place)//(k-1) if (n-place)%(k-1)==0 else (n-place)//(k-1)+1

print(l+r)

Submission status: Wrong Answer

Solution code:
inputs = input()
inputa = input()

NK=inputs.split()
inputn= inputa.split()
N = int(NK[0])
K = int(NK[1])

input_line=[]
for num in inputn:
    input_line.append(int(num))

cnt = 0

min_n = min(input_line)
length = len(input_line)

cp = 0
Klist=[]

for i in range(N):
    if input_line[i] == 1:
        onep=i
        break
        
before = onep
after = N-1 - onep

bmod=before % (K-1)
if bmod == 0:
    bdivide=before //(K-1)
else:
    bdivide=(before-bmod) // (K-1)
    bdivide+=1

amod=after % (K-1)
if amod == 0:
    adivide=after //(K-1)
else:
    adivide=(after-amod) // (K-1)
    adivide+=1


cnt = bdivide + adivide 
if K==N:
    cnt == 1
print(cnt)

Submission status: Wrong Answer

Solution code:
inputs = input()
inputa = input()

NK=inputs.split()
inputn= inputa.split()
N = int(NK[0])
K = int(NK[1])

input_line=[]
for num in inputn:
    input_line.append(int(num))

cnt = 0

min_n = min(input_line)
length = len(input_line)

cp = 0
Klist=[]

for i in range(N):
    if input_line[i] == 1:
        onep=i
        break
        
before = onep
after = N-1 - onep

bmod=before % (K-1)
if bmod == 0:
    bdivide=before //(K-1)
else:
    bdivide=(before-bmod) // (K-1)
    bdivide+=1

amod=after % (K-1)
if amod == 0:
    adivide=after //(K-1)
else:
    adivide=(after-amod) // (K-1)
    adivide+=1

cnt = bdivide + adivide 
print(cnt)

Submission status: Wrong Answer

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

m = min(A)
p = A.index(m)

res = N

for i in range(K):
    if p > K+i-1:
        continue
    elif p >= N-i:
        continue
    else:
        if p-K+i+1 > 0:
            left = -(-(p-K+i+1)//(K-1))
        else:
            left = 0
        if N-p-i-1 > 0:
            right = -(-(N-p-i-1)//(K-1))
        else:
            right = 0
        res = min(res, left + right + 1)
print(res)

Submission status: Wrong Answer

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

m = min(A)
p = A.index(m)

res = N

for i in range(K):
    if p > K+i-1:
        continue
    elif p >= N-i:
        continue
    else:
        left = -(-(p-K+i+1)//(K-1))
        right = -(-(N-p-i-1)//(K-1))
        res = min(res, left + right + 1)
print(res)

Submission status: Wrong Answer

Solution code:
inputs = input()
inputa = input()

NK=inputs.split()
inputn= inputa.split()
N = int(NK[0])
K = int(NK[1])

input_line=[]
for num in inputn:
    input_line.append(int(num))

cnt = 0

min_n = min(input_line)
length = len(input_line)

break_flag = 0

for i in range(N):
    if i + 1 == length-1 and input_line[i+1] != min_n:
        cnt+=1
        break
    elif i+1 == length-1:
        break
    if input_line[i+1] != min_n:
        cnt += 1
        for p in range(K):
            if i+p >= length:
                break
            else:
                input_line[i+p] = min_n

print(cnt)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

index = arr.index(1)

left = ceil(index / (k - 1))

if left:
    right = ceil((n - left * k) / (k - 1))
else:
    right = ceil((n - 1) / (k - 1))

print(left + right)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

index = arr.index(1)

left = ceil(index / (k - 1))
right = ceil((n - left * k) / (k - 1))

print(left + right)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

index = arr.index(1)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=input().split()
m=a.index("1")
a,b=m,n-m-1
ans=((a+1)//(k-1))+1
b-=a%(k-1)
ans+=((b+1)//(k-1))+1
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

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

a_min = min(A)
for i, j in enumerate(A):
    if j == a_min:
        location = i
        break

left = copy.deepcopy(location)
right = len(A) - location - 1

ans = 0
if left % (K-1) == 0:
    ans += left // (K-1)
else:
    ans += left // (K-1) + 1

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

answer = (N-1)//(K-1)+2
print(answer)

Submission status: Wrong Answer

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

idx = A.index(1)

left = idx
right = N-idx-1

answer = 0
for x in [left,right]:
  answer += (x-1)//(K-1)+1
print(answer)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
A=[int(i) for i in input().split()]
print(math.ceil(n/k))

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 =  [ int(v) for v in input().split() ]
num_list = [ int(v) for v in input().split() ]

if n <= k:
	ans = 1
else:
	ans =  ( n + (k-2) ) // (k-1)

print(ans)

Submission status: Wrong Answer

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

if n <= k:
	ans = 1
else:
	ans =  ( n + (k-2) ) // (k-1)

Submission status: Wrong Answer

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

if n <= k:
	ans = 1
else:
	ans = n + (k-2) // (k-1)

Submission status: Wrong Answer

Solution code:
n, k =  [ int(v) for v in input().split() ]
num_list = [ int(v) for v in input().split() ]
start = num_list.index(1)
left = start
right = n - 1- start

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

print(left+right)

Submission status: Wrong Answer

Solution code:
n, k =  [ int(v) for v in input().split() ]
num_list = [ int(v) for v in input().split() ]
start = num_list.index(1)
left = start
right = n - 1- start

left = (left + k - 1) // k
right = (right + k - 1) // k

print(left+right)

Submission status: Wrong Answer

Solution code:
import math
n,m=map(int,input().split())
print(math.ceil(n/m))

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=list(map(int,input().split()))
P=A.index(1)
X=P
Y=N-P-1
K-=1
if K>=min(X,Y):
  print(ceil((N-1)/K))
else :
  print(ceil(X/K)+ceil(Y/K))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ind = As.index(min(As))
n = len(As)
print((n-ind)//(K-1)+(ind+1)//(K-1))

Submission status: Wrong Answer

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

min_a = min(A)
ans = 0
for i in range(len(A)-1):
    if A[i+1] != min_a:
        for j in range(K):
            if i + j > len(A) - 1:
                break
            else:
                A[i+j] = min_a
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, K, *A = map(int, open(0).read().split())
l = A.index(1)
r = N - l - 1
print((l - 1) // (K - 1) + (r - 1) // (K - 1) + 2)

Submission status: Wrong Answer

Solution code:
import numpy as np 
n, k = map(int, input().split())
seq = list(map(int, input().split()))
index = [i for i in range(len(seq)) if seq[i]==1][0]
left = index
right = n - index - 1
#print(index, left, right)
if index>0 and index<n:
    left_time = int(np.ceil(left / (k-1)))
    right_time = int(np.ceil(right / (k-1)))
    print(left_time+right_time)
else:
    time = int(np.ceil((n-1) / (k-1)))
    print(time)

Submission status: Wrong Answer

Solution code:
import math
N, K = [int(t) for t in input().split()]
A = [int(t) for t in input().split()]

idx = A.index(1)
left = A[:idx+1]
right = A[idx:]


def get_cnt(L):
    return math.ceil((len(L) - 1) / (K-1))


if idx + 1 < K or N - idx < K:
    print(get_cnt(A))
else:
    print(get_cnt(left) + get_cnt(right))

Submission status: Wrong Answer

Solution code:
import math
N, K = [int(t) for t in input().split()]
A = [int(t) for t in input().split()]

idx = A.index(1)
left = A[:idx+1]
right = A[idx:]

print(idx)
print(left)
print(right)


def get_cnt(L):
    return math.ceil((len(L) - 1) / (K-1))


if idx + 1 < K or N - idx < K:
    print(get_cnt(A))
else:
    print(get_cnt(left) + get_cnt(right))

Submission status: Wrong Answer

Solution code:
import math
N, K = [int(t) for t in input().split()]
A = [int(t) for t in input().split()]

idx = A.index(1)
left = A[:idx+1]
right = A[idx:]


def get_cnt(L):
    return math.ceil((len(L) - 1) / (K-1))


if len(left) < K or len(right) < K:
    print(get_cnt(A))
else:
    print(get_cnt(left) + get_cnt(right))

Submission status: Wrong Answer

Solution code:
def calc_distance(m):
  global B
  update=False
  for i,z in enumerate(B):
    if z==m:
      if i>=1 and (B[i-1]==None or B[i-1]>z+1):
        B[i-1]=z+1
        update=True
      if len(B)>i+1 and(B[i+1]==None or B[i+1]>z+1):
        B[i+1]=z+1
        update=True
  if update:
    calc_distance(m+1)

N,K=list(map(int,input().split(" ")))
A=list(map(int,input().split(" ")))
minA=min(A)
B=[]
ans=0
for z in A:
  if z==minA:
    B.append(0)
  else:
    B.append(None)

#for z in range(len(B)):
#  if B[z]==0:
#    calc_distance(0)
flag=True
while flag:
  if not(None in B):
    break
  leftNone=B.index(None)
  leftZero=B.index(0)

  if leftNone < leftZero:
    p=0
    while True:
      if 0 in B[p:p+K]:
        ans+=1
        for z in range(p,p+K):
          B[z]=0
        break
      p+=1
  else:
    ds=len(B)-2-leftZero
    ans+=ds//(K-1)
    flag=False
if ans==0:
  ans=1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
    if A[i] == 1:
        break
ans = 10e9
for j in range(k):
    left = len(A[:i])
    right = len(A[i+1:])
    left = math.ceil(left / (k-1))
    right = math.ceil(right / (k-1))
    ans = min(ans, left+right)
print(ans)

Submission status: Wrong Answer

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

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

b = 1  
r = N - (K - 1)  
while r > K:
  r -= b*(K - 1)
  b += 1

print(b+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

a = A.index(1)
#print (a)
#すべてindexで処理する
b = (a + 1 + K-2)//(K-1) #左端から1までの個数をKを1回ごとに進む数で割って切り上げ
#print (b)
c = b * (K-1) #上記の処理をしたときの右端のindex

if c >= (N-1): #右端のindexがリストの長さを超えている時
    print (b)
else: #右側にまだ数字が残っている時
    d = (N-1) - c #残っている数
    e = (d+(K-1))//(K-1)
    print (b + e)

Submission status: Wrong Answer

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

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

a = A.index(1)
#print (a)
#すべてindexで処理する
b = (a + K-2)//(K-1) #左端から1までの個数をKを1回ごとに進む数で割って切り上げ
#print (b)
c = b * (K-1) #上記の処理をしたときの右端のindex

if c >= (N-1): #右端のindexがリストの長さを超えている時
    print (b)
else: #右側にまだ数字が残っている時
    d = (N-1) - c #残っている数
    e = (d+(K-1))//(K-1)
    print (b + e)

Submission status: Wrong Answer

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

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

a = A.index(1)

#すべてindexで処理する
b = (a + 1 +(K-1))//(K-1) #左端から1までの個数をKを1回ごとに進む数で割って切り上げ

c = b * (K-1) #上記の処理をしたときの右端のindex

if c >= (N-1): #右端のindexがリストの長さを超えている時
    print (b)
else: #右側にまだ数字が残っている時
    d = (N-1) - c #残っている数
    e = (d+(K-1))//(K-1)
    print (b + e)

Submission status: Wrong Answer

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


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


def main():
    n, k = intin()
    alist = intina()

    for i, a in enumerate(alist):
        if a == 1:
            i1 = i
            break

    if i1 % (k - 1):
        left = i1 // (k - 1) + 1
    else:
        left = i1 // (k - 1)

    if left:
        right_pos = n - left * (k - 1)
    else:
        right_pos = n - 1

    if right_pos % (k - 1):
        right = right_pos // (k - 1) + 1
    else:
        right = right_pos // (k - 1)

    print(left + right)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


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


def main():
    n, k = intin()
    alist = intina()

    for i, a in enumerate(alist):
        if a == 1:
            i1 = i
            break

    if i1 % (k - 1):
        left = i1 // (k - 1) + 1
    else:
        left = i1 // (k - 1)

    right_pos = n - i1 - 1
    if right_pos % (k - 1):
        right = right_pos // (k - 1) + 1
    else:
        right = right_pos // (k - 1)

    print(left + right)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

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

one_index = A.index(1)

total = 0

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

if one_index != 0:

    left_length = len(A[0:one_index]) + 1

    if K >= left_length:
        total += 1
    else:
        total += (left_length // (K - 1))

if one_index != len(A):
    right_length = len(A[one_index:])

    if K >= right_length:
        total += 1
    else:
        total += (right_length // (K - 1))

print(total)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

X = A[0]
index = 0
cnt = 0

while index < N:
    end_index = min(index + K, N)
    sub = [A[x] for x in range(index, end_index)]
    flag = 0
    for k in sub:
        if k != X:
            k = X
            flag += 1
    if flag != 0:
        cnt += 1
    index += K - 1

print(cnt)

Submission status: Wrong Answer

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

one_index = A.index(1)

print(max(0, len(A[0:one_index]) // (K - 1)) + max(0, len(A[one_index:]) // (K - 1)))

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
xs = list(map(int, input().split()))

'''
if k == n:
  print(1)
  exit()
'''
  
idx = xs.index(1) # where 1 locates

result = N
for m in range(K - 1):
  L = idx - m
  if L < 0:
    continue
  R = N - K - idx + m
  if R < 0:
    continue
  cnt = lambda a: 0 if a == 0 else math.ceil(a / (K -1))
  result = min(result, 1 + sum(cnt(b) for b in [L, R]))
  
print(result)

Submission status: Wrong Answer

Solution code:
n,k = map (int,input().split())
a = tuple ( map ( int , input().split()))
one = a.index(1)
lc,rc = 0,0
if one != 0 :
      lc = round( one / (k-1) - 0.5)+1
r = n - one - 1 + (one % (k-1))
if one != k + 1 :
      rc = round( r / (k-1) - 0.5) +1
print (lc + rc)

Submission status: Wrong Answer

Solution code:
n,k = map (int,input().split())
a = tuple ( map ( int , input().split()))
one = a.index(1)
lc = round( one / (k-1) - 0.5)+1
r = n - one - 1 + (one % (k-1))
rc = round( r / (k-1) - 0.5) +1
print (lc + rc)

Submission status: Wrong Answer

Solution code:
n,k = map (int,input().split())
a = tuple ( map ( int , input().split()))
one = a.index(1)
lc = round( one / (k-1) + 0.5)+1
r = n - one - 1 + (one % (k-1))
rc = round( r / (k-1) - 0.5) +1
print (lc + rc)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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