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())
data = map(int, input().split())
one_left = 0
if k == 2:
    print(n//(k-1)-1)
else:
    for i in data:
        if i != 1:
            one_left += 1

    one_right = n - one_left - 1

    if one_left == 0 or one_right == 0:
        print(n//(k-1))

    else:
        left_cnt = one_left // (k-1)
        right_cnt = one_right // (k-1)
        print(left_cnt + right_cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math, sys
 
def LI(): return [int(x) for x in sys.stdin.readline().split()]
 
n, k = LI()
a = LI()
l = len(a[:a.index(1)])
r = len(a[a.index(1):])
 
left = math.ceil((l - k) / (k - 1)) + 1
right = math.ceil((r - k) / (k - 1)) + 1
 
print(left + right)

Submission status: Wrong Answer

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

n=(N-1)//(K-1)

print(n+1)

Submission status: Wrong Answer

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

Pos = a.index(1)

cnt = 0
lPos = Pos
while  lPos > 0:
    lPos -= (k - 1)
    cnt += 1

rPos = Pos
while rPos < (len(a) - 1):
    rPos += (k - 1)
    cnt += 1
 
print(cnt)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
s = 0

a = [0]
a = input().split()

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

print(s)

Submission status: Wrong Answer

Solution code:
def m():
    def solve(n,k):
        if n <= k:
            return 1
        ans = 1
        ans += (n-k) // (k-1)
        if n-k % k-1 == 0:
            return ans
        return ans + 1
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    pos = a.index(1)
    if pos <= k-1 or pos >= n - k:
        return solve(n,k)
    left = a[pos:]
    right = a[:pos+1]
    if k == 2:
        right = a[:pos]
    return solve(len(left), k) + solve(len(right),k)
print(m())

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
 
ind = a.index(1)
 
left = ind
right = n-1-ind
import math
if left<(k-1):
	right -= k-1-left
elif right<(k-1):
	left -= k-right-1
if k>=n:
	print (1)
else:
	print(int(math.ceil(left/(k-1))+math.ceil(right/(k-1))))

Submission status: Wrong Answer

Solution code:
import sys

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil

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

Submission status: Wrong Answer

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

if n <= k:
    ans = 1
else :
    ans = 0
    while n >= 0:
      n = n - k + 1
      ans += 1
      
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = [int(x) for x in input().strip().split()]
    line = [int(x) for x in input().strip().split()]
    counter = K - 1
    result = 0
    while counter < N:
        counter += K - 1
        result += 1
    if counter - (K - 1) < N:
        result += 1
    print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#/usr/bin/env python3

import math

if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    print(max(1, math.ceil((len(A) - K) / 2) + 1))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
minIndex = A.index(min(A))
cnt1 = (minIndex+1)//(K-1)
cnt2 = (len(A)-max(minIndex, 1))//(K-1)
print(cnt1 + cnt2)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
if K == N:
  print(1)
elif K > N/2:
  print(2)
elif K < N/2:
  print(N - K - 1)
elif K == 2:
  print(N - 1)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split(" "))
#A,B = input().split(" ")
A = list(map(int,input().split(" ")))
min = min(A)
i = A.index(min)
bot = i
up = i
cou = 0
while(up<N-1):
    up = up + M-1
    cou = cou + 1
while(bot>0):
    bot = bot - M-1
    cou = cou + 1

print(cou)

Submission status: Wrong Answer

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

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

min_A = min(A)


ind1 = A.index(1)
len1 = len(A) -ind1
len2 = ind1 + 1
print((len1-1)//(K-1)-1+1 + (len2-1)//(K-1)-1+1)

Submission status: Wrong Answer

Solution code:
def endo(N, K):
    result=(N-1)//(K-1)
    if not (N-1)%(K-1)==0:
        result+=1

    return result

N,K=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
i=A.index(1)
result=max([endo(i,K)+endo(N-i+1,K), endo(i-1,K)+endo(N-i,K)+1])
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
index1=a.index(1)
if k>=index1 or len(a)-(index1+1)<=k:
    print(round((len(a)-1)/(k-1)))
else:
    ans=float("inf")
    for i in range(k):
        ans=min(ans,1+round((index1+1-k)/k)+round((len(a)-(index1+1))/k))
    print(ans)

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:
        min_a=i+1
        break

x = min_a-1
y = N-min_a


ans=x//(K-1)+y//(K-1)

if x%(K-1)>0:
    ans=ans+1
if y%(K-1)>0:
    ans=ans+1

print(ans)

Submission status: Wrong Answer

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

if n <= k:
    ans = 1
else :
    ans = 0
    while n > 0:
      n = n - k + 1
      ans += 1
      
print(ans)

Submission status: Wrong Answer

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

min_num = A.index(m)
  
n1 = min_num 
n2 = N - min_num - 1

res = math.ceil(n1/(K-1)) + math.ceil(n2/(K-1))
    
print(res)

Submission status: Wrong Answer

Solution code:
import math

l = raw_input().split()
N = int(l[0])
K = int(l[1])

l1 = raw_input().split()

print(int(math.floor(N/(K-1))))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a_min = min(a)
a_min_index = a.index(min(a))
left = a_min_index
right = n - a_min_index - 1
import math
result = math.ceil(left / (k - 1)) + math.ceil(right / (k - 1))
if (n % 2 != 0) and (a_min_index + 1) == math.ceil(n/2):
    print(result + 1)
elif n == k:
    print(1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = [int(_) for _ in input().split()]
min_index = a.index(min(a))
left = min_index
right = min_index
cnt = 0
while left > 0 or right < n - 1:
  if left > 0:
    left -= (k - 1)
    cnt += 1
  if right < n - 1:
    right += (k - 1)
    cnt += 1
    
print(cnt if n > k else '1')

Submission status: Wrong Answer

Solution code:
#/usr/bin/env python3

import math

if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    print(max(0, math.ceil((len(A) - K) / 2) + 1))

Submission status: Wrong Answer

Solution code:
str = input()
n, k = str.split(' ')
ni = int(n)
ki = int(k)
str = input()

if ni == ki:
    print(1)
elif ki == 2:
    print(ni-1)
else:
    print(int((ni-1)/(ki-1))+1)

Submission status: Wrong Answer

Solution code:
import math

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

index_1 = An.index(min(An))

if N > 2:
    num_of_leftside = index_1
    num_of_rightside = (N-1)-index_1
else:
    num_of_leftside = len([i for i in range(0, index_1)])
    num_of_rightside = len([i for i in range(index_1, N)])


if num_of_rightside % 2 == 1 and num_of_leftside % 2 == 1:
    count = 0
    count += 1
    num_of_leftside -= 1
    count += int(math.ceil(num_of_leftside / (K-1)))
    num_of_rightside -= 1
    count += int(math.ceil(num_of_rightside / (K-1)))
    print(count)
else:
    print(int(math.ceil(num_of_leftside / (K-1))) + int(math.ceil(num_of_rightside / (K-1))))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
 
ind = a.index(1)
 
left = ind
right = n-1-ind
import math
if left<k:
	right -= k-ind-1
elif right<k:
	left -= k-right-1
if k>=n:
	print (1)
else:
	print(int(math.ceil(left/(k-1))+math.ceil(right/(k-1))))

Submission status: Wrong Answer

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

A = [i for i in input().split()]

if N == K:
    print(1)

elif K - 1 == 1:
    print(N -1)

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

Submission status: Wrong Answer

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

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

min_A = min(A)


ind1 = A.index(1)
len1 = len(A) -ind1
len2 = ind1 + 1
print(len1//(K-1)-1+1 + len2//(K-1)-1+1)

Submission status: Wrong Answer

Solution code:
N, k = map(int, input().split())
num = input().rstrip().split()

t = 0

for i in range(N):
  if num[i] == "1":
    one = i
    break
    
left = one
right = N - one - 1


while(right > 0):
  right -= (k-1)
  t += 1

while(left > 0):
  left -= (k-1)
  t += 1


print(t)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    argmin = 0
    for i in range(N):
        if 1 == int(input_raw[i]):
            argmin = i
    if K == N:
        print 1
        exit()
    if argmin  < K - 1:
        argmin = K - 1
    if argmin  > N - K and argmin + 1 < N:
        argmin = N - K
    L = argmin
    R = (N - 1) - argmin
    print (L/(K -1) + L % (K -1)) + (R/(K -1) + R % (K -1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import floor
nk = input()
n, k = nk.split()
n = int(n)
k = int(k)

an = input()
an_list = an.split()
min = min(an_list)

min_ind = an_list.index(min) + 1
after = (n - min_ind) / (k-1)
before = (min_ind - 1) / (k-1)

res = 0

if after.is_integer():
    res = res + after
else:
    res = res + floor(after) + 1

if before.is_integer():
    res = res + before
else:
    res = res + floor(before) + 1


if n/2 < k:
    res = floor(n/k) + 1

print(int(res))

Submission status: Wrong Answer

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

if n <= k:
    ans = 1
elif n % k == 0:
    ans = n / k + 1
else :
    ans = 0
    while n > 0:
      n = n - k + 1
      ans += 1
      
print(ans)

Submission status: Wrong Answer

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

min_ad = A.index(1)+1


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

Submission status: Wrong Answer

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

# print(N)
# print(K)
# print(perm)

if N <= 1:
    print(0)
elif N <= K:
    print(1)
else:
    print(int((N - 1) / (K - 1)))

Submission status: Wrong Answer

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

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

min_idx = A.index(min(A))

# print("N: {}\nK: {}\nA: {}\nmin_idx: {}".format(N,K,A,min_idx))

if N <= K:
    print(1)
else:
    K -= 1
    rtn = 0
    idx = min_idx
    while(idx < N - 1):
        idx += K
        rtn += 1

    idx = min_idx
    while idx > 0:
        idx -= K
        rtn += 1

    print(rtn)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
start = [i for i,x in enumerate(a) if x == max(a)]
m = 10000000
for i in start:
    if math.ceil(i/(k-1))+math.ceil(((n-1)-i)/(k-1)) < m:
        m = math.ceil(i/(k-1))+math.ceil(((n-1)-i)/(k-1))
print(m)

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
a = list(map(int, input().split()))
if n % (k-1) == 2 and n/(k-1) == 1:
    print(2)
else:
    print(int(math.floor((n/(k-1)))))

Submission status: Wrong Answer

Solution code:

n, k = map(int, input().rstrip().split(' '))
an = list(map(int, input().rstrip().split(' ')))

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

b_c = an.index(1)
a_c = n - (b_c + 1)

min = 0
if an[0] != '1' and b_c < k:
    a_c = a_c - (k - (b_c + 1))
    min += 1
    min += -(-a_c // (k-1))
elif an[-1] != '1' and a_c < k:
    b_c = b_c - (k - (a_c + 1))
    min += -(-b_c // (k-1))
    min += 1
else:
    min += -(-b_c // (k-1))
    min += -(-a_c // (k-1))

print(min)

Submission status: Wrong Answer

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

if i < N/2:
    right = N - (i + K -1) -1
    left = i
else:
    right = N - i - 1
    left = i - (K -1)

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

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

print(cright+cleft+1)

Submission status: Wrong Answer

Solution code:
import math
def main15():
    strbuf1 = input('');
    strbuf2 = input('');
    strbufs1 = strbuf1.split();
    strbufs2 = strbuf2.split();
    buf1 = [];
    buf2 = [];
    ba = 0;
    for i in range(2):
        buf1.append(int(strbufs1[i]));
    for i in range(buf1[0]):
        buf2.append(int(strbufs2[i]));
        if(buf2[i] == 1):
            ba = i;
    are = buf1[1] - 1;
    kai1 = math.ceil(ba/are);
    kai2 = math.ceil((buf1[0] -(ba+1))/are)
    print(int(kai1+kai2));




if __name__ == '__main__':
    main15()

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
 
ind = a.index(1)
 
left = ind
right = n-1-ind
import math
if left<k:
	right -= k-ind-1
elif right<k:
	left -= k-right-1
print (left, right)
if k>=n:
	print (1)
else:
	print(int(math.ceil(left/(k-1))+math.ceil(right/(k-1))))

Submission status: Wrong Answer

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

min_num = A.index(m)
  
n1 = min_num 
n2 = N - min_num - 1

res = math.ceil(n1/2) + math.ceil(n2/2)
    
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

        print(count)

Submission status: Wrong Answer

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

A = [int(i) for i in input().split(' ' )]
index_1 = -1

for i in range(len(A)):
    #print(index_1)
    if A[i]==1:
        index_1 = i
        break

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

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

Submission status: Wrong Answer

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

import math
x=A.index(1)
y=N-x-1

ans=math.ceil(x/(K-1))+math.ceil(y/(K-1))
print(ans)

Submission status: Wrong Answer

Solution code:
nk = input().split(" ")
n = int(nk[0])
k = int(nk[1])
a = input()
if n == k:
	print("1")
else:
	s = -(-n // (k-1))
	print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def m():
    def solve(n,k):
        if n <= k:
            return 1
        ans = 1
        ans += (n-k) // (k-1)
        if n-k % k-1 == 0:
            return ans
        return ans + 1
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    pos = a.index(1)
    if pos <= k-1 or pos >= n - k:
        return solve(n,k)
    left = a[pos:]
    right = a[:pos+1]
    return solve(len(left), k) + solve(len(right),k)
print(m())

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
a_min = min(a)
a_min_index = a.index(min(a))
left = a_min_index
right = n - a_min_index - 1
import math
result = math.ceil(left / (k - 1)) + math.ceil(right / (k - 1))
if (n % 2 != 0) and (a_min_index + 1) == math.ceil(n/2):
    print(result + 1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math

if __name__ == "__main__":
    n,k = map(int,input().split())
    a = input().split(" ")
    prev = True
    pre,post = (0,0)
    remain = k
    for i in range(n):
        a[i] = int(a[i])
        if a[i] != 1 and prev == True:
            pre += 1
        if a[i] == 1:
            prev = False
            if pre < remain-1:
                a[i+1] = 1
                remain -= 1
        if a[i] != 1 and prev == False:
            post += 1

    result = 0
    result += math.ceil(pre / (k-1))
    result += math.ceil(post / (k-1))

    print(result)

Submission status: Wrong Answer

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

# print(N)
# print(K)
# print(perm)

if N <= 1:
    print(0)
elif N <= K:
    print(1)
else:
    print(int((N - 1) / (K - 1)))

Submission status: Wrong Answer

Solution code:
from math import ceil

N, K = map(int, input().split())
A = list(map(int, input().split()))
index_one = 0
count = 0
for i in range(len(A)):
    if A[i] == 1:
        index_one = i
count += ceil(index_one/(K-1))
count += ceil((N - index_one - 1)/(K-1))
print(count)

Submission status: Wrong Answer

Solution code:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
ls = Is()
_1 = ls.index(1)
if _1 < k-1:
    _1 = k-1
elif _1 >= n-k:
    _1 = n-k
print(math.ceil(_1/(k-1))+math.ceil((n-1-_1)/(k-1)))

Submission status: Wrong Answer

Solution code:
def get_score(amount, limit):
    s = limit - 1
    tmp = amount // s
    return tmp if (amount % s) == 0 else tmp + 1


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

key = a.index(1)
left = key
right = n - key

r = get_score(left, k) + get_score(right, k)

print(r)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().rstrip().split(' '))
an = list(map(int, input().rstrip().split(' ')))

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

b_c = an.index(1)
a_c = n - (b_c + 1)

min = 0
if b_c != 0 and b_c < k:
    a_c = a_c - (k - (b_c + 1))
    min += 1
    min += -(-a_c // (k-1))
elif b_c != n-1 and a_c < k:
    b_c = b_c - (k - (a_c + 1))
    min += -(-b_c // (k-1))
    min += 1
else:
    min += -(-b_c // (k-1))
    min += -(-a_c // (k-1))

print(min)

Submission status: Wrong Answer

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

min_num = A.index(m)
  
n1 = min_num 
n2 = N - min_num - 1

if n1 == 0:
    res = math.ceil(n2/2)
elif n2 == 0:
    res = math.ceil(n1/2)
else:
    res = math.ceil(n1/2) + math.ceil(n2/2)
    
print(res)

Submission status: Wrong Answer

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

x = a[0]
e = 4
for i in a:
    if not x == a:
        break
    else:
        e -= 1

if e == 0:
    ans = 0
elif n <= k:
    ans = 1
elif n % k == 0:
    ans = n / k
else :
    ans = 0
    while n > 0:
      n = n - 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)
 
left = ind
right = n-1-ind
import math
if left<k:
	right -= k-ind
if k>=n:
	print (1)
else:
	print(int(math.ceil(left/(k-1))+math.ceil(right/(k-1))))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = [int(_) for _ in input().split()]
min_index = a.index(min(a))
left = min_index
right = min_index
cnt = 0
while left > 0 or right < n - 1:
  if left > 0:
    left -= (k - 1)
    cnt += 1
  if right < n - 1:
    right += (k - 1)
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

inde = A.index(1)

if inde == 0 or inde == N-1:
	print(math.ceil((N - 1) / (K-1)))
elif inde < K or N - inde - 1 < K:
	print(1 + math.ceil((N-K)/(K-1)))
else:
	print(math.ceil(inde / (K-1)) + math.ceil((N - inde - 1) / (K-1)))

Submission status: Wrong Answer

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

    mindex = a.index(1)

    t = (mindex+k-2) // (k-1) + (len(a)-mindex+k-3) // (k-1)

    if k % 2 == 1:
        t2 = 1 + (mindex+k-3) // (k-1) + (len(a)-(mindex+1)+k-3) // (k-1)
        t = min(t, t2)

    print(t)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
index1=a.index(1)
ans=round((len(a)-1)/(k-1))

for i in range(len(a)):
    if index1+1+i<=k:
        continue
    ans=min(ans,round((index1+i-k)/(k-1))+1+round((len(a)-index1+i)/(k-1)))
print(ans)

Submission status: Wrong Answer

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

min_position = A.index(1)
left = min_position
right = N - 1 - left
if (left >= K and right >= K):
    left_num = left // (K - 1) 
    right_num = right // (K - 1)
    if N - (left_num + right_num) * (K - 1) <= K:
        print(left_num + right_num + 1)
    else:
        print(left_num + right_num + 2)
else:
    print(1 + (N - K + 1) // (K - 1))

Submission status: Wrong Answer

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

a1 = a.index(1)
sol = 0
a_left = a1
a_right = len(a)-1-a1
if a_left % (k-1) == 0:
    sol += int(a_left / (k-1))
else:
    sol += int(a_left / (k-1)) + 1
if a_right % (k-1) == 0:
    sol += int(a_right / (k-1))
else:
    sol += int(a_right / (k-1)) + 1

print(sol)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if i < N/2:
    right = N - (i + K -1) -1
    left = i
else:
    right = N - i - 1
    left = i - (K -1)

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

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

print(int(cright+cleft+1))

Submission status: Wrong Answer

Solution code:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
ls = Is()
_1 = ls.index(1)
if _1 < k-1:
    _1 = k-1
elif _1 > n-k:
    _1 = n-k
print(math.ceil(_1/(k-1))+math.ceil((n-1-_1)/(k-1)))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().rstrip().split(' '))
an = list(map(int, input().rstrip().split(' ')))

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

b_c = an.index(1)
a_c = n - (b_c + 1)

min = 0
if b_c < k:
    a_c = a_c - (k - (b_c + 1))
    min += 1
    min += -(-a_c // (k-1))
elif a_c < k:
    b_c = b_c - (k - (a_c + 1))
    min += -(-b_c // (k-1))
    min += 1
else:
    min += -(-b_c // (k-1))
    min += -(-a_c // (k-1))

print(min)

Submission status: Wrong Answer

Solution code:
# coding : utf-8
import math

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

# 全部を最小値1にする必要がある
minNum = 1
minIndex = A.index(minNum)

# 最小値1の左側の個数
leftNum = minIndex
#print(leftNum)

# 最小値1の右側の個数
rightNum = N - leftNum - 1
#print(rightNum)

# 左側の変換について、最初のステップを右側の数を含めても同じ回数になる場合
leftMod = leftNum % (K-1)
if leftMod != 0:
    rightNum -= leftMod
    if rightNum < 0:
        rightNum = 0

# 右側の変換について、最初のステップを左側の数を含めても同じ回数になる場合
rightMod = rightNum % (K-1)
if rightMod != 0:
    leftNum -= rightMod
    if leftNum < 0:
        leftNum = 0

leftCount = math.ceil( leftNum / (K-1) )

rightCount = math.ceil( rightNum / (K-1) )

ans = leftCount + rightCount

print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

Pos = a.index(1)
r = ceil(((len(a) - 1) - Pos) / (k - 1))
l = ceil(Pos / (k - 1))
print(r + l)

Submission status: Wrong Answer

Solution code:
str = input()
n, k = str.split(' ')
ni = int(n)
ki = int(k)
str = input()

if ni == ki:
    print(1)
else:
    print(int((ni-1)/(ki-1))+1)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = [int(x) for x in input().strip().split()]
    line = [int(x) for x in input().strip().split()]
    counter = 0
    result = 0
    while counter < N:
        counter += K - 1
        result += 1
    print(result)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = input().split()
lines = []
lines.append(input().split())
if int(K)%int(N) ==0:
    a = int(N)/int(K)
else:
    a = int(N)/int(K)+1
print(int(a))

Submission status: Wrong Answer

Solution code:
import math

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

index_1 = An.index(min(An))

if N > 2:
    num_of_leftside = index_1
    num_of_rightside = (N-1)-index_1
else:
    num_of_leftside = len([i for i in range(0, index_1)])
    num_of_rightside = len([i for i in range(index_1, N)])
    
#print(index_1)
# print(num_of_leftside, num_of_rightside)
print(int(math.ceil(num_of_leftside / (K-1))) + int(math.ceil(num_of_rightside / (K-1))))

Submission status: Wrong Answer

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

center = A.index(1)
left_block = center + 1
right_block = len(A) - center

left_num = 0
if left_block > K:
    tmp = left_block
    while tmp > 0:
        tmp = tmp - K + 1
        left_num += 1
elif 2 <= left_block <= K:
    left_num = 1

right_num = 0
if right_block > K:
    tmp = right_block
    while tmp > 0:
        tmp = tmp - K + 1
        right_num += 1
elif 2 <= right_block <= K:
    right_num = 1

print(left_num + right_num)

Submission status: Wrong Answer

Solution code:
import math

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

res = 0
if A.index(1) < K or A.index(1) > len(A) - K:
    print(int(N/(K-1)))
else:
    index = A.index(1)
    res += math.ceil(index/(K-1))
    print(res)
    res += math.ceil((len(A) - index - 1) / (K-1))
    print(int(res))

Submission status: Wrong Answer

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

one_index = a.index(1) + 1

# 大きい方
if(one_index != n):
    bigger = n-one_index
    while True:
        if(bigger <= 0):
            break
        bigger -= k-1
        count += 1

if(one_index != 1):
    # 小さい方
    one_index -= 1
    while True:
        if(one_index <= 0):
            break
        one_index -= k-1
        count += 1

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

(N, K) = list(map(int, input().split()))
rawA = input()
A = [int(i) for i in rawA.split(' ')]

# 1の位置を探す
i = A.index(1)
n_minus = math.ceil(i / (K - 1))
n_plus = math.ceil((N - 1 - i) / (K - 1))
print(n_minus + n_plus)

Submission status: Wrong Answer

Solution code:
from math import floor
nk = input()
n, k = nk.split()
n = int(n)
k = int(k)

an = input()
an_list = an.split()
min = min(an_list)

min_ind = an_list.index(min) + 1
after = (n - min_ind) / (k-1)
before = (min_ind - 1) / (k-1)

res = 0

if after.is_integer():
    res = res + after
else:
    res = res + floor(after) + 1

if before.is_integer():
    res = res + before
else:
    res = res + floor(before) + 1

print(int(res))

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
 
ind = a.index(1)
 
left = ind
right = n-1-ind
import math
if k>=n:
	print (1)
else:
	print(int(math.ceil(left/(k-1))+math.ceil(right/(k-1))))