Problem: 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.

Submission attempts (in order):
n,k = map(int,input().split())

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)

counter = 0
mn = min(left_length,right_length)
mx = max(left_length,right_length)

mx -= mn % (k-1)

while mn > 0:
    counter += 1
    mn -= k-1

mx -= mn % (k-1)

while mx > 0:
    counter += 1
    mx -= k-1




print(counter)

#n=6 k=4
#
# 3 1 2 4 5 6


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

id_of_one = lst.index(1) 

left = len(lst[0:id]) 
right = len(lst[id+1:]) 
total = left + right

amari = max(left%(k-1),right%(k-1))
total -= amari



counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one]-1)
right_length = len(lst[id_one:]-1)

counter = 0

if left_length > 0:
    left_length -= k
    counter += 1

while left_length > 0:
    counter += 1
    left_length -= k-1

if right_length > 0:
    counter += 1
    right_length -= k

while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
print(left_length)
right_length = len(lst[id_one:])-1
print(right_length)
counter = 0


if min(left_length,right_length) < k-1:
    if left_length < right_length:
        right_length -= left_length%(k-1)
    else:
        left_length -= right_length%(k-1)


while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)

counter = 0
mn = min(left_length,right_length)
mx = max(left_length,right_length)
total = mn + mx
total -= mn % (k-1)

while total > 0:
    total -= k-1
    counter += 1



print(counter)

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

id_of_one = lst.index(1) 

left = len(lst[0:id_of_one]) 
right = len(lst[id_of_one+1:]) 
total = left + right

amari = max(left%(k-1),right%(k-1))
total -= amari



counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

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

id_of_one = lst.index(1) 

left = len(lst[0:id_of_one]) 
right = len(lst[id_of_one+1:]) 
total = left + right





counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted