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:
from sys import stdin


def main():
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    A = [int(x) for x in stdin.readline().rstrip().split()]
    if N == K:
        print(1)
        return
    idx = A.index(1)
    result = 0
    if K < idx or idx < (N - K):
        count = N
        while count > 0:
            count -= (K - 1)
            result += 1
        print(result)
    else:
        print(result - 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np
listA=list(map(int,input().split()))
N=listA[0]
K=listA[1]
A=list(map(int,input().split()))
Anp=np.array(A)
if(N/K==1):
        print(1)
elif((N-1)%(K-1)==0):
    print((N-1)/(K-1))
else:
    print(int((N-1)/(K-1))+1)

Submission status: Wrong Answer

Solution code:
from sys import stdin



n_s, k_s = stdin.readline().rstrip().split() # 問題文に出てくるA，B，Cが空白区切りで1行で入力される場合はアンパック代入が便利
a_s_l = stdin.readline().rstrip().split() # 問題文に出てくるA，B，Cが空白区切りで1行で入力される場合はアンパック代入が便利

N = int(n_s)
K = int(k_s)
A = []
for i in a_s_l:
    A.append(int(i))

AA = A
count = 0
j = K - 1
for i, a in enumerate(A):
    if N == K :
        count = count + 1
        break
    elif i > N - K:
        buf = AA[N - K : N]
        count = count + 1
    elif j== i :
        buf = AA[i : i + K]
        count = count + 1
        j = i + K - 1
    
print(count)

Submission status: Wrong Answer

Solution code:
count = 0
N,K = map(int,input().split( ))
J = list(map(int,input().split( )))
for i,j in zip(range(1,N+1),J):
    if j==1:
        s = i
        t = N-s+1
for _ in range(N):
    if s-K+1<=0:
        count += 1
        break
    else:
        s -= K-1
        count += 1

for _ in range(N):
    if t+K-1>=N:
        count += 1
        break
    else:
        t += K-1
        count += 1
print(count)

Submission status: Wrong Answer

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

print(int((N-1)/(K-1))+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
lt = k - left - 1
right = n - key
rt = k - right - 1

r_tmp = lt if lt > 0 else 0
r1 = get_score(left, k) + get_score(right - r_tmp, k)

l_tmp = rt if rt > 0 else 0
r2 = get_score(left - l_tmp, k) + get_score(right, k)

print(min(r1, r2))

Submission status: Wrong Answer

Solution code:
def Minimization(N,K,Alist):
    minindex = Alist.index(min(Alist))
    leftnum = minindex
    rightnum = N - (minindex + 1)
    print((-(-leftnum // (K-1)))+(-(-rightnum // (K-1))))
N,K = list(map(int,input().split()))
Alist = input().split()
Alist = list(map(int,Alist))
Minimization(N,K,Alist)

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

if K == len(A):
    print(1)
elif K >= len(A) // 2:
    print(2)
else:
    if K == 2:
        print(len(A) - 1)
    else:
        cnt1 = (minIndex+1)//(K-1)
        cnt2 = (len(A)-minIndex)//(K-1)
        print(cnt1 + cnt2)

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の位置を探す
def minimization(N, K, A):
    i = A.index(1)
    n = math.ceil(i / (K - 1))
    if N - i <= K:
        p = 1
    else:
        p = math.ceil((N - i) / (K - 1))
    return n, p


n_minus, n_plus = minimization(N, K, A)
print(n_minus + n_plus)

Submission status: Wrong Answer

Solution code:
#coding: utf-8

inputN, inputK = map(int, input().split())
inputA = list(map(int, input().split()))
minNumber = inputN
minPos = 0

for i in range(len(inputA)):
    if inputA[i] < minNumber:
        minNumber = inputA[i]
        minPos = i

splitNumber = (inputN+1) / (inputK-1)
print (int(splitNumber))

Submission status: Wrong Answer

Solution code:
import math

s = input().rstrip().split()

n = int(s[0])
k = int(s[1]) - 1

a = list(map(int, input().rstrip().split()))

b = a.index(1)
if(n == k + 1):
    print(1)
else:
    print(math.ceil(b / k) + math.ceil((n - b - 1) / k))

Submission status: Wrong Answer

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

a = list(map(int, input().split()))
plus = 0
minus = 0

for i in range(len(a)):
  if a[i] == 1:
    min = i + 1

if (min-1)%(K-1) + (N-min)%(K-1) > (K-1):
  minus += 1
else:
  if (min-1)%(K-1) > 0:
    plus += 1
  if (N-min)%(K-1) > 0:
    plus += 1
  

print((min-1)//(K-1) + (N-min)//(K-1) + plus - minus)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
'''
pos = 0
for i in range(n):
    if a[i] == 1:
        pos = i+1
'''
if n == k:
    ans = 1
else:
    ans = 2 + (n-k) // (k-1)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

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

if n != k:
    ind = nums.index(1)

    print(math.ceil((n-1-ind)/ (k-1)) + math.ceil((ind)/(k-1)))
elif n == k:
    print(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))

if K == len(A):
    print(1)
elif K > len(A) // 2:
    print(2)
else:
    if K == 2:
        print(len(A) - 1)
    else:
        cnt1 = (minIndex+1)//(K-1)
        cnt2 = (len(A)-minIndex)//(K-1)
        print(cnt1 + cnt2)

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 == k:
    print(1)
else:
    print(result)

Submission status: Wrong Answer

Solution code:
#coding: utf-8

inputN, inputK = map(int, input().split())
inputA = list(map(int, input().split()))
minNumber = inputN
minPos = 0

for i in range(len(inputA)):
    if inputA[i] < minNumber:
        minNumber = inputA[i]
        minPos = i

splitNumber = (inputN+1) / (inputK-1)
print (splitNumber)

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
if min_index < k or min_index > n - k - 2:
  cnt -= 1

print(cnt if n > k else '1')

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
l = input().split()
 
cnt=0
end_point=0 
for i,e in enumerate(l):
    if i !=end_point:
        continue 
    #print(i)
    #print(e)
    #print(l)
    #print(l[i:i+K])
    m= min(l[i:i+K])
    try:
        cnt =cnt+1
        for j in range(K):
            l[i+j]=m
    except:
        print(cnt)
    end_point=i+j

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
n, k = map(int,input().split())
a = list(map(int,input().split()))
h = 10000000
i = np.argmin(a)
m = math.ceil(i/(k-1))+math.ceil(((n-1)-i)/(k-1))
if a[0]==min(a) or a[n-1]==min(a):
    if math.ceil((n-1)/(k-1)) != 0:
        h = math.ceil((n-1)/(k-1))
print(min(h,m))

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

if N == k:
  t = 1
  left=0
  right=0
  
elif left < k - 1:
  left = 0
  right -= (k - 1) - left
  t += 1
  
elif right < k - 1:
  right = 0
  left -= (k - 1) - right
  t+=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:
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

kk = (K-1)//2

if x==y and K%2==1:
    if (x-kk)%(K-1)==0 and (y-kk)%(K-1)==0:
       ans = ans-1

if N==K:
    ans = 1

print(ans)

Submission status: Wrong Answer

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

for i in range(int(N)):
  if As[i]==1: index = i

num = index//int(K) + (int(N)-index)//int(K) +2

print(num)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = 0
m = 0
if a[0] == 1 or a[1]==1 or a[2]==1:
    for i in range(n-2):
        if a[i] == a[i+1] == a[i+2] or a[i] == a[i+1]:
            if a[i+2] == a[n-1]:
                a[i] = min(a[i],a[i+1],a[i+2])
                a[i+1] = min(a[i],a[i+1],a[i+2])
                a[i+2] = min(a[i],a[i+1],a[i+2])
                ans+= 1
            else:
                continue

        else:
            a[i] = min(a[i],a[i+1],a[i+2])
            a[i+1] = min(a[i],a[i+1],a[i+2])
            a[i+2] = min(a[i],a[i+1],a[i+2])
            ans+= 1
else:
    for i in range(n):
        if a[i+2]==1:
            m = i
            break
    for i in range(m,n-2):
        if a[i] == a[i+1] == a[i+2] or a[i] == a[i+1]:
            if a[i+2] == a[n-1]:
                a[i] = min(a[i],a[i+1],a[i+2])
                a[i+1] = min(a[i],a[i+1],a[i+2])
                a[i+2] = min(a[i],a[i+1],a[i+2])
                ans+= 1
            else:
                continue
        else:
            a[i] = min(a[i],a[i+1],a[i+2])
            a[i+1] = min(a[i],a[i+1],a[i+2])
            a[i+2] = min(a[i],a[i+1],a[i+2])
            ans+= 1
    for i in reversed(range(m)):
        if a[i] == a[i-1] == a[i-2] or a[i] == a[i-1]:
            if a[i-2] == a[0]:
                a[i] = min(a[i],a[i-1],a[i-2])
                a[i+1] = min(a[i],a[i-1],a[i-2])
                a[i+2] = min(a[i],a[i-1],a[i-2])
                ans+= 1
            else:
                continue
        else:
            a[i] = min(a[i],a[i-1],a[i-2])
            a[i+1] = min(a[i],a[i-1],a[i-2])
            a[i+2] = min(a[i],a[i-1],a[i-2])
            ans+= 1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

if A[0] == 1 or A[N-1] == 1:
    print(math.ceil((N-K) / (K-1)+1))
elif N == K:
    print(1)
else:
    print(math.ceil(((A.index(1)+1)-1) /(K-1)) + math.ceil((N-A.index(1)-1) /(K-1)))

Submission status: Wrong Answer

Solution code:
n, k = [int(i) for i in input().split()]
input()
if n == k:
    print(1)
elif k == 1:
    print(n)
elif n % (k-1) == 0:
    print(int(n/(k-1)))
else:
    print(int(n/(k-1)) + 1)

Submission status: Wrong Answer

Solution code:
def cost(M, m):
    if M == 0:
        return M
    
    else:
        return M // m + 1 - int(M%m==0)
      
l = input().split()

N = int(l[0])
K = int(l[1])

A = input().split()

for i in range(N):
    if A[i] == '1':
        break

left = i
right = N - 1 - i

if N == K:
    print(1)
    
elif left + 2 <= K:
    print( cost(N-K, K-1) + 1)
    
elif right + 2 <= K:
    print( cost(N-K, K-1) + 1)
    
else:
    l_cost = cost(left, K-1)
    r_cost = cost(right, K-1)
    print(l_cost + r_cost)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
min_idx = A.index(min(A))
tmp = min_idx
count = 0
while tmp > 0:
    tmp -= (K - 1)
    count += 1

a = N - min_idx - 1
while a > 0:
    a -= (K - 1)
    count += 1
    
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:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
import math

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

if n == k:
    print(1)
else:
    print(math.ceil(int(n / (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
lt = k - left - 1
right = n - key
rt = k - left - 1

r_tmp = lt if lt > 0 else 0
r1 = get_score(left, k) + get_score(right - r_tmp, k)

l_tmp = rt if rt > 0 else 0
r2 = get_score(left - l_tmp, k) + get_score(right, k)

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

print(min(r1, r2))

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
    min_op = sys.maxint
    for i in range(K):
        L = argmin - i
        R = ((N - 1) - argmin + i)
        op = (L/(K -1) + L % (K -1)) + (R/(K -1) + R % (K -1))
        if op < min_op:
            min_op = op
    print min_op


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
count = 0
N,K = map(int,input().split( ))
J = list(map(int,input().split( )))
for i,j in zip(range(1,N+1),J):
    if j==1:
        s = i
        t = N-s+1
for _ in range(N):
    if s-K<=0:
        count += 1
        break
    else:
        s -= K-1
        count += 1

for _ in range(N):
    if t-K<=0:
        count += 1
        break
    else:
        t -= K-1
        count += 1
print(count)

Submission status: Wrong Answer

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

if N == K:
    Ans = 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:
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()]

front = 0
tail = 0
count = 0

for i in range(N):
    if A[i] == 1:
        break
    else:
        front += 1
tail = N - (front + 1)

count += (front + 1)//2
count += (tail + 1)//2

if front == 1:
    count -= 1

print(count)

Submission status: Wrong Answer

Solution code:
import math

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

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

one_index = a_list.index(1)

kyori_a=len(a_list)-one_index
kyori_b=one_index+1

print(math.ceil(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の位置を探す
def minimization(N, K, A):
    i = A.index(1)
    n = math.ceil(i / (K - 1))
    if N - i == K:
        p = 1
    else:
        p = math.ceil((N - i) / (K - 1))
    return n, p


n_minus, n_plus = minimization(N, K, A)
print(n_minus + n_plus)

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))
if K == len(A):
    print(1)
else:
    if K == 2:
        print(len(A) - 1)
    else:
        cnt1 = (minIndex+1)//(K-1)
        cnt2 = (len(A)-minIndex)//(K-1)
        print(cnt1 + cnt2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
N , K = map(int,input().split())
A =  list(map(int,input().split()))


n = np.argmin(A)
m = N - n - 1
if n < m:
    res = int(n/(K-1))
    reminder= n % (K-1)
    if reminder != 0:
        m_new = m - (reminder)
        res = res + 1
    else:
        m_new = m
    res += int(m_new/(K-1))
    reminder = m_new % (K-1)
    if reminder != 0:
        res = res + 1
else:
    temp = n
    n = m
    m = temp
    res = int(n/(K-1))
    reminder= n % (K-1)
    if reminder != 0:
        m_new = m - (reminder)
        res = res + 1
    else:
        m_new = m
    res += int(m_new/(K-1))
    reminder = m_new % (K-1)
    if reminder != 0:
        res = res + 1
print(res)

Submission status: Wrong Answer

Solution code:
import math

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

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

print(math.ceil(n / (c - 1)))

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:
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 K < min(n1, n2):
    if n1 != n2:
        res = math.ceil(n1/(K-1)) + math.ceil(n2/(K-1))
    else:
        res = math.ceil((n1-1)/(K-1)) + math.ceil((n2-1)/(K-1)) + 1
else:
    res = math.ceil((max(n1, n2) - (K - min(n1, n2)))/(K-1)) + 1

print(res)

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 = N -ind1
len2 = ind1 + 1

r1= 0
if (len1-1)%(K-1) != 0:
    r1 = 1

r2= 0
if (len2-1)%(K-1) != 0:
    r2 = 1
d = 0

r3= 0
if (len1-2)%(K-1) != 0:
    r3 = 1

r4= 0
if (len2-2)%(K-1) != 0:
    r4 = 1
d = 0

ans1 = (len1-1)//(K-1)+r1 + (len2-1)//(K-1)+r2
ans2 = (len1-2)//(K-1)+r3 + (len2-2)//(K-1)+r4 + 1

print(min(ans1, ans2))

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
        l=k-1
if (n-l)>=k:
    if (n-l-1)%(k-1)!=0:
        x=x+(n-l-1)//(k-1)+1
    else:
        x=x+(n-l-1)//(k-1)
else:
    if l==n-1:
        x=x
    else:
        x=x+1
print(x)

Submission status: Wrong Answer

Solution code:
import math

s = input().rstrip().split()

n = int(s[0])
k = int(s[1]) - 1

a = list(map(int, input().rstrip().split()))

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

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

if left + right + 1 <= k:
  t = 1
  left=0
  right=0
  
elif left < k - 1:
  left = 0
  right -= (k - 1) - left
  t += 1
  
elif right < k - 1:
  right = 0
  left -= (k - 1) - right
  t+=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:
N, M = map(int, raw_input().split())

a = []
a.append(map(int, raw_input().split()))

keylist = range(N)
colum = M
valuelist = a

A = {k: v for k, v in zip(keylist, valuelist)}


minkey = min(A, key = A.get)
minnum = min(A.values())


sum1 = 0

if minkey%(colum-1) != 0:
    sum1 = sum1 + (minkey//(colum-1))+1 
    
    
else:
    sum1 = sum1 + minkey//(colum-1)

num1 = N - minkey

if num1%(colum-1) != 0:
    sum1 = sum1 + (num1//(colum-1))
else: 
     sum1 = sum1 + num1//(colum-1)

print sum1

Submission status: Wrong Answer

Solution code:
#c
count = 0
N,K = map(int,input().split( ))
J = list(map(int,input().split( )))
for i,j in zip(range(1,N+1),J):
    if j==1:
        s = i
        t = N-s+1
for _ in range(N):
    if s-K<=0:
        count += 1
        break
    else:
        s -= K-1
        count += 1
        print(count)

for _ in range(N):
    if t-K<=0:
        count += 1
        break
    else:
        t -= K-1
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
l = input().split()
 
cnt=0
end_point=0 
for i,e in enumerate(l):
    if i !=end_point:
        continue 
    #print(i)
    #print(e)
    #print(l)
    #print(l[i:i+K])
    m= min(l[i:i+K])
    try:
        cnt =cnt+1
        for j in range(K):
            l[i+j]=m
    except:
        print(cnt)
    end_point=i+j
#print(cnt)
if i==len(e)-1:
    print(cnt)

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
        l=k-1
if (n-l)>k:
    if (n-l-1)%(k-1)!=0:
        x=x+(n-l-1)//(k-1)+1
    else:
        x=x+(n-l-1)//(k-1)
else:
    if l==n-1:
        x=x
    else:
        x=x+1
print(x)

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
min_num = N

if (left >= K and right >= K):
    for k in range(K):
        left_num = max(0, left - k)
        right_num = min(0, right + K - 1 - k) 
        min_num = min(min_num, (left_num + 1) // (K - 1) + (right_num + 1) // (K - 1) + 1)
    print(min_num + 1)
else:
    print((N - K + 1) // (K - 1) + 1)

Submission status: Wrong Answer

Solution code:
n,k=input().split()
array=list(map(int,input().split()))
n=int(n)
k=int(k)
#print(k)
i=0
while k+i*(k-1)<=n:
    i+=1

print(i+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding:utf-8 -*-

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

F=0
for i in A:
    if i==1:
        X=F 
        Y=N-(F+1)
        break;
    F=F+1

qX=X//K
qY=Y//(K-1)

modX=X%K
modY=Y%(K-1)

#print(F,qX,qY,modX,modY)
if modX>0:
    AnsX = qX+1
else:
    AnsX=qX

if modY>0:
    AnsY=qY+1
else:
    AnsY=qY
print(AnsX+AnsY)

Submission status: Wrong Answer

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

#len(a) == n

#print(n//(k-1))
long_pla =  a.index(min(a)) + 1
if (n - long_pla) % (k-1) + long_pla % (k-1)>= (k-1):
    print(n//(k-1)+1)
else:
    print(n//(k-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))
if K == len(A):
    print(1)
else:
    if K == 2:
        cnt1 = (minIndex+1)  - 1
        cnt2 = (len(A)-minIndex) - 1
    else:
        cnt1 = (minIndex+1)//(K-1)
        cnt2 = (len(A)-minIndex)//(K-1)
    print(cnt1, cnt2)
    print(cnt1 + cnt2)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
A = list(map(int,input().split()))
mnidx = A.index(min(A))
left = mnidx-0
right = N-mnidx-1
ans = math.ceil(left/K)
ans += math.ceil(right/(K-1))
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

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

if N==K:
    ans = 1

print(ans)

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
        if tmp == K:
            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
        if tmp == K:
            right_num -= 1
elif 2 <= right_block <= K:
    right_num = 1

print(left_num + right_num)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
min_idx = A.index(min(A))
tmp = min_idx
count = 0
while tmp >= 1:
    tmp -= (K - 1)
    count += 1

a = (N - min_idx) - 1
while a >= 1:
    a -= (K - 1)
    count += 1
    
print(count)

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
min_num = N

if (left >= K and right >= K):
    for k in range(K):
        left_num = max(0, left - k)
        right_num = min(0, right + K - 1 - k) 
        min_num = min(min_num, (left_num + 1) // (K - 1) + (right_num + 1) // (K - 1) + 1)
    print(min_num)
else:
    print((N - K + 1) // (K - 1) + 1)

Submission status: Wrong Answer

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

i = A.index(1)
ans1 = ans2 = ans3 = 1000010
if N<=K:
    print(1)
    exit()
if len(A[:i]) < K-1:
    ans1 = -(-len(A[:i])//(K-1)) + -(-(len(A[i+1:]) - (K-len(A[:i])))//(K-1))
if len(A[i+1:]) < K-1:
    ans2 = -(-(len(A[:i]) - (K-len(A[i+1:])))//(K-1)) + -(-len(A[i+1:]))//(K-1)
if len(A[:i]) >= K-1 and len(A[i+1:]) >= K-1:
    ans3 = -(-len(A[:i])//(K-1)) + -(-len(A[i+1:])//(K-1))

ans = min(ans1,ans2,ans3)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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
        else:
            break

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

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

Submission status: Wrong Answer

Solution code:

def main():
    n, k = [int(i.strip()) for i in input().split(' ')]
    s = [int(i.strip()) for i in input().split(' ')]

    idx = s.index(1)
    m1, c1 = divmod(len(s[idx:]), k-1)
    m2, c2 = divmod(len(s[:idx])+1, k-1)
    print(m1+m2)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
count = 0
N,K = map(int,input().split( ))
J = list(map(int,input().split( )))
for i,j in zip(range(1,N+1),J):
    if j==1:
        s = i
        t = N-s+1
for _ in range(N):
    if s-K<=0:
        count += 1
        break
    else:
        s -= K-1
        count += 1
        print(count)

for _ in range(N):
    if t-K+1<=0:
        count += 1
        break
    else:
        t -= K-1
        count += 1
print(count)

Submission status: Wrong Answer

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

import math
if N==K:
	print(1)
else:
	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:
import math

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

if A[0] == 1 or A[N-1] == 1:
    print(math.ceil((N-K) / (K-1)+1))
else:
    print(math.ceil(((A.index(1)+1)-1) /(K-1)) + math.ceil((N-A.index(1)-1) /(K-1)))

Submission status: Wrong Answer

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

lis = list(map(int,input().split()))
if n == k:
    print("1")
    exit()
cou = 0
cou += math.ceil(lis.index(min(lis)) / (k-1))
cou += math.ceil((n-lis.index(min(lis))-1)/(k-1))
print(cou)

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
min_num = N

if (left >= K and right >= K):
    for k in range(K):
        left_num = max(0, left - k)
        right_num = min(0, right + K - 1 - k) 
        min_num = min(min_num, (left_num + 1) // (K - 1) + (right_num + 1) // (K - 1) + 1)
    print(min_num - 1)
else:
    print((N - K + 1) // (K - 1) + 1)

Submission status: Wrong Answer

Solution code:
from math import ceil

N, K = tuple(map(int, input().split()))

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

l = len(A)

i = A.index(1)
rs = ceil((l - 1 - i)/(K-1))
ls = ceil(i/(K-1))
if ((ls - i) < K):
    i = ls - K - 1
    ls = ceil(i/(K-1))
elif (i + 1 < K):
    i = K - 1
    rs = ceil((ls - 1 - i)/(K-1))

if (N != K):
    res = ls + rs
elif (N == K):
    res = 1


print(res)