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 math import ceil

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n <= k:
    print(1)
    exit()
res = 0
# 1の範囲を増やしていくという方向性？
range_left = array.index(1)
range_right = n - range_left
# 一度に変更できるのはk-1個(1を含めないといけないため)
k -= 1
if range_left == 0:
    res += ceil(range_right/k)
    print(res)
    exit()
elif range_right == 0:
    res += ceil(range_left/k)
    print(res)
    exit()

if range_left <= k:
    res += 1
    range_right -= (k - range_left)
    res += ceil(range_right / k)
else:
    res += ceil(range_left / k)
    range_right -= range_left%k
    res += ceil(range_right / k)
print(res)

Submission status: Wrong Answer

Solution code:
from math import ceil

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n == k:
    print(1)
    exit()
res = 0
# 1の範囲を増やしていくという方向性？
index_1 = array.index(1) + 1
index_2 = n - index_1 + 1
if index_1 <= k:
    res += 1
    index_2 -= (k - index_1)
    res += index_2 // k + 1
else:
    res += (index_1 // k + 1)
    if index_2 == 1:
        print(res)
        exit()
    index_2 -= max(0, index_1 % k - 1)
    res += index_2 // k+1
print(res)

Submission status: Wrong Answer

Solution code:
from math import ceil

n, k = map(int, input().split())
array = [int(x) for x in input().split()]

if n == k:
    print(1)
    exit()
res = 0
# 1の範囲を増やしていくという方向性？
index_1 = array.index(1) + 1
index_2 = n - index_1 + 1

if index_1 <= k:
    res += 1
    index_2 -= (k - index_1)
    res += index_2 // k + 1
else:
    res += (index_1 // k + 1)
    index_2 -= max(0, index_1 % k - 1)
    res += index_2 // k+1
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
N,K=map(int,input().split(" "))
a=list(map(int,input().split(" ")))
c=Counter(a).most_common(1)
index=a.index(c[0][0])
tmp=index
sum=0
if(c[0][1]==1):
    print(N//K+N%K)
else:
    for n in range(index,N):
        if(a[n]==c[0][0]):
            sum+=(abs(tmp-n)//K+abs(tmp-n)%K)
        tmp=n
    print(sum)

Submission status: Wrong Answer

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

pos_1 = A_arr.index(1)
lef = pos_1
rig = N - (pos_1 + 1)

lef_int = lef // (K-1)
lef_per = 0 if lef % (K-1) == 0 else 1
rig_int = rig // (K-1)
rig_per = 0 if rig % (K-1) == 0 else 1

if lef % (K-1) + rig % (K-1) == K-1:
    print(lef_int+lef_per+rig_int+rig_per-1)
else:
    print(lef_int+lef_per+rig_int+rig_per)

Submission status: Wrong Answer

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

pos_1 = A_arr.index(1)
lef = pos_1
rig = N - (pos_1 + 1)

lef_int = lef // (K-1)
lef_per = 0 if lef % (K-1) == 0 else 1
rig_int = rig // (K-1)
rig_per = 0 if rig % (K-1) == 0 else 1


if lef % (K-1) + rig % (K-1) >= K-1:
    print(lef_int+lef_per+rig_int+rig_per-1)
else:
    print(lef_int+lef_per+rig_int+rig_per)

Submission status: Wrong Answer

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

pos_1 = A_arr.index(1)
lef = pos_1
rig = N - (pos_1 + 1)

lef_int = lef // (K-1)
lef_per = 0 if lef % (K-1) == 0 else 1
rig_int = rig // (K-1)
rig_per = 0 if rig % (K-1) == 0 else 1

print(lef_int+lef_per+rig_int+rig_per)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split())) 
if (N-K)%2!=0:
	print((N-K)//2+2)
else:
  print((N-K)//2+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k,*a=map(int,open(0).read().split())
b=a.index(min(a))
ans=0
if len(a[b+1:])%(k-1)==0:
  ans+=len(a[b+1:])//(k-1)
else:
  ans+=len(a[b+1:])//(k-1)+1
if len(a[:b])%(k-1)==0:
  ans+=len(a[:b])//(k-1)
else:
  ans+=len(a[:b])//(k-1)+1
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
n = len(set(A))
cnt = 0
s = 0
turn = 0
while s < n:
    cnt += 1
    if turn == 0:
        s += k
        turn = 1
    else:
        s += k - 2
        turn  = 0
print(cnt)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
cnt = 0
s = 0
turn = 0
while s < n:
    cnt += 1
    if turn == 0:
        s += k
        turn = 1
    else:
        s += k - 2
        turn  = 0
print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

P = min(A)

print(A.index(P)//(K-1) + (N - A.index(P))//(K-1))

Submission status: Wrong Answer

Solution code:
import math

int_n, int_k = map(int, input().split())
ar_int_a = list(map(int, input().split()))

idx_minimum = ar_int_a.index(min(ar_int_a))
left = math.ceil(idx_minimum / (int_k - 1)) if idx_minimum != 0 else 0
right = math.ceil((int_n - (idx_minimum + 1)) / (int_k - 1)) if idx_minimum != (int_n - 1) else 0

print(left + right)

Submission status: Wrong Answer

Solution code:
# C
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = n-k
if n-k == 0:
    print(1)
else:
    result = 1 + (n-k) // (k-1)
    if n-k % (k-1) != 0:
        result += 1
    print(result)

Submission status: Wrong Answer

Solution code:
import numpy
n,r=map(int,input().split())
l=list(map(int,input().split()))
key=l.index(1)
if key!=0 and key!=n-1:
  ans=numpy.ceil(key/(r-1))+numpy.ceil((n-key-1)/(r-1))
else:
  ans=numpy.ceil((n-1)/(r-1))
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy
n,r=map(int,input().split())
l=list(map(int,input().split()))
key=l.index(1)
ans=numpy.ceil((1+key)/r)+numpy.ceil((n-key)/r)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy
n,r=map(int,input().split())
l=list(map(int,input().split()))
key=l.index(1)
ans=numpy.ceil((1+key)/r)+numpy.ceil((n-key+2)/r)
print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy
n,r=map(int,input().split())
l=list(map(int,input().split()))
key=l.index(1)
ans=numpy.ceil(key/r)+numpy.ceil((n-key+1)/r)
print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if n==1:
    print(1)
else:
    print(n//2)

Submission status: Wrong Answer

Solution code:
from math import ceil


class Solver(object):
    def __init__(self):
        self.n, self.k = list(map(int, input().split(" ")))
        self.a_s = list(map(int, input().split(" ")))

    def solve(self):
        if self.n == self.k:
            print(1)
        elif self.k == 2:
            return self.n - 1
        else:
            print(ceil(self.n / (self.k-1)))


if __name__ == "__main__":
    s = Solver()
    s.solve()

Submission status: Wrong Answer

Solution code:
from math import ceil


class Solver(object):
    def __init__(self):
        self.n, self.k = list(map(int, input().split(" ")))
        self.a_s = list(map(int, input().split(" ")))

    def solve(self):
        if self.n == self.k:
            print(1)
        else:
            print(ceil(self.n / (self.k-1)))


if __name__ == "__main__":
    s = Solver()
    s.solve()

Submission status: Wrong Answer

Solution code:
import math
n,k=list(map(int, input().split()))
K=k-1
L=list(map(int, input().split()))
x=0
l=[]
for i in range(n):
    if L[i]==1:
        l.append(x//K+math.ceil((x%K)/K))
        x=0
    else:
        x+=1
if not L[n-1]==1:
    l.append(x//K+math.ceil((x%K)/K))
print(sum(l))

Submission status: Wrong Answer

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

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

l = 0
r = 0
one = False
for i in range(n):
    if a[i] == 1:
        one = True
        continue
    if one == False:
        l += 1
    else:
        r += 1

b = max(l,r)
if b%(k-1) == 0:
    b //= k-1
else:
    b //= k-1
    b += 1

c = min(l,r)+1 - k
if c%(k-1) == 0:
    c //= k-1
else:
    c //= k-1
    c += 1
print(b+c+1)

Submission status: Wrong Answer

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

l = 0
r = 0
one = False
for i in range(n):
    if a[i] == 1:
        one = True
        continue
    if one == False:
        l += 1
    else:
        r += 1

if l % (k-1) == 0:
    l //= k-1
else:
    l //= k-1
    l += 1
    
if r % (k-1) == 0:
    r //= k-1
else:
    r //= k-1
    r += 1
print(l+r)

Submission status: Wrong Answer

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

noMinLen = len(Alist) - Alist.count(min(Alist))
if noMinLen % 2 != 0:
    noMinLen += 1

print(noMinLen // (K-1))

Submission status: Wrong Answer

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

mini = min(Alist)
miniidx = [i for i, x in enumerate(Alist) if x == mini]

cacheidx = 0
count = 0
if K == N:
    count = 1
else:
    for idx in miniidx:
        diff = idx - cacheidx
        count += diff//(K-1)
        cacheidx = idx

    diff = len(Alist) - miniidx[-1]
    count += diff//(K-1)

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N ,K = map(int,input().split())
L = list(map(int,input().split()))
def ceil(x):
    if x == int(x):
        return x
    else:
        return int(x) + 1


cnt = 0

N = N - K 
cnt += 1
if N > 0:
    cnt += ceil(N / (K-1))
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

idx = A.index(1) + 1
left = idx - 1
right = N - idx
K -= 1

print(math.ceil(left/K) + math.ceil(right/K))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
S = input().split()
A = [int(s) for s in S]
if len(A) - K <= 0:
    print(1)
else:
    print(int((len(A)-K)/(K-1)) + 2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

min_i = [i for i, n in enumerate(A) if n == 1]

min_i = min_i[0]

def length_from_min(length):
    mod = 0 if length % (K - 1) == 0 else 1
    return length // (K - 1) + mod

answer = length_from_min(min_i) + length_from_min(N - min_i - 1)

print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N,K = map(int, lines.pop(0).split(' '))
    A = list(map(int, lines.pop(0).split(' ')))
    min_a = min(A)
    idx = 0
    re = 0
    while( idx < N ):
        if ( all([i == min_a for i in A[idx:idx+K] ]) ):
            idx += K - 1
            continue
        else:
            re += 1
            idx += K - 1
    print(re)



#
# main
#

# 1. use list instead of stdin

# contents = '''\
# 10 3
# 7 3 2 1 1 1 1 5 5 5\
# '''
# lines = contents.split('\n')
# 
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
min_a = a.index(min(a))
ans = 0
for i in range(0, min_a-1, k-1):
    ans += 1
for i in range(min_a, len(a)-1, k-1):
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
[print((n[0] - 2) / (n[1] - 1) + 1) for n in [list(map(int, input().split()))]]

Submission status: Wrong Answer

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

import math
print(math.floor(n / (k-1)))

Submission status: Wrong Answer

Solution code:
import math

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

min_idx = A.index(min(A))

count = N
start = max(0,min_idx-K+1)
end = min(start+K, N)
for i in range(start, end):
    tmp = math.ceil(i/(K-1)) + math.ceil((N-(i+K))/(K-1))
    if count > tmp:
        count = tmp

print(tmp+1)

Submission status: Wrong Answer

Solution code:
import math

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

min_idx = A.index(min(A))

count = N
start = max(0,min_idx-K+1)
end = start + K
for i in range(start, end):
    tmp = math.ceil(i/(K-1)) + math.ceil((N-(i+K))/(K-1))
    if count > tmp:
        count = tmp

print(tmp+1)

Submission status: Wrong Answer

Solution code:
import math

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

min_idx = A.index(min(A))

count = N
for i in range(max(0,min_idx-K+1), min_idx+1):
    tmp = math.ceil(i/(K-1)) + math.ceil((N-(i+K))/(K-1))
    if count > tmp:
        count = tmp

print(tmp+1)

Submission status: Wrong Answer

Solution code:
import math

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

min_idx = A.index(min(A))

count = N
for i in range(min(0,min_idx-K+1), min_idx+1):
    tmp = math.ceil(i/(K-1)) + math.ceil((N-(i+K))/(K-1))
    if count > tmp:
        count = tmp

print(tmp+1)

Submission status: Wrong Answer

Solution code:
import math

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

min_idx = A.index(min(A))

count = N
for i in range(min_idx-K+1, min_idx+1):
    tmp = math.ceil(i/(K-1)) + math.ceil((N-(i+K))/(K-1))
    if count > tmp:
        count = tmp

print(tmp+1)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(0, 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()))
for i in range(n):
    if a[i] == 1:
        x = i

ans = 0
ans += x // (k - 1)
ans += 1 if x % (k - 1) != 0 else 0
ans += (n-x-1) // (k - 1)
ans += 1 if (n-x-1) % (k - 1) != 0 else 0
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def main():
    from math import floor

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

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


if __name__ == '__main__':
    main()

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)
l, r = i, N-i-1
if N == K:
    print(1)
elif l < K-1:
    l, r = 0, r - (K-l-1)
    print(ceil(l/(K-1)) + ceil(r/(K-1)) + 1)
elif r < K-1:
    l, r = l - (K-r-1), 0
    print(ceil(l/(K-1)) + ceil(r/(K-1)) + 1)
else:
    print(ceil(l/(K-1)) + ceil(r/(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)
l, r = i, N-i-1
if l < K-1:
    l, r = 0, r - (K-l-1)
    print(ceil(l/(K-1)) + ceil(r/(K-1)) + 1)
elif r < K-1:
    l, r = l - (K-r-1), 0
    print(ceil(l/(K-1)) + ceil(r/(K-1)) + 1)
else:
    print(ceil(l/(K-1)) + ceil(r/(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/(K-1)) + ceil((N-i-1)/(K-1)))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
# def search(A):
#     for i in range(N):
#         if A[i] == 1:
#             return i
# n = search(A)
#
# print(-(-n//(K-1)) + -(-(N-1-n)//(K-1)))
print((N-1) // (K-1))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
# def search(A):
#     for i in range(N):
#         if A[i] == 1:
#             return i
# n = search(A)
#
# print(-(-n//(K-1)) + -(-(N-1-n)//(K-1)))
print((N+1) // (K-1))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
def search(A):
    for i in range(N):
        if A[i] == 1:
            return i
n = search(A)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math

def main():
    na = list(map(int, input().split()))
    N, K = na[0], na[1]
    A = list(map(int, input().split()))

    i1 = A.index(1)
    r = 0
    if i1 < K or N - K <= i1:
        r = math.ceil((N - 1) / (K - 1))
    else:
        r = math.ceil(i1 / (K - 1)) + math.ceil((N - i1 - 1) / (K - 1))

    print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n -= 3
count = 1
while n > 0:
    n -= 2
    count += 1
    
print(count)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
series = list(map(int,input().split()))
onepoint=series.index(1)
start = max(0,onepoint-K+1)
end = min(len(series),onepoint+K)
#print("start=",start,"end=",end)
ans = 10**9
for p in range(start,end):
	tmp = 0
	back = p
	front = p + K
	#print("back=",-(-back // (K-1)))
	#print("front=",-(-(len(series)-front) // (K-1)))
	tmp += -(-back // (K-1)) #Round Up
	tmp += -(-(len(series)-front) // (K-1))
	#print("tmp=",tmp)
	if ans > tmp:
		ans = tmp

print(tmp+1)

Submission status: Wrong Answer

Solution code:
import math

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

base = A.index(1)
left = base
right = len(A) - 1 - base

print(math.ceil(left/K)+math.ceil(right/K))

Submission status: Wrong Answer

Solution code:
import math

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

base = A.index(1)
left = base
right = len(A) - 1 - base
K -= 1

print(math.ceil(left/K)+math.ceil(right/K))

Submission status: Wrong Answer

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

min_A = min(A)
max_index = n-1
max_iter = 0

list_A = []
start_pos = 0
while(True):
    list_A.append(A[start_pos:start_pos+k])
    start_pos += k-1
    if start_pos +k > n:
        list_A.append(A[start_pos:n])
        break

count = 0
for part_A in list_A:
    if len(set(A)) == len(A) and A[0] == min_A:
        pass

    else:
        count +=1 
print(count)

Submission status: Wrong Answer

Solution code:
import math

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

index = A.index(min(A))
max_index = n-1
ans = 0

ans += math.ceil(index/float(k-1))
ans += math.ceil((max_index-index)/float(k-1))

print(ans)

Submission status: Wrong Answer

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

n -= 3
count = 1

while n > 0:
    n -=2
    count += 1
    
print(count)

Submission status: Wrong Answer

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

a = l.index(1)
ans = math.ceil((N-K)/(K-1)) + 1
if (a%(K-1))!=0 and ((N-a-1)%(K-1))!=0:
  ans += 1

print(ans)

Submission status: Wrong Answer

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

a = l.index(1)
print(math.ceil(a/(K-1)) + math.ceil((N-a-1)/(K-1)))

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = input()
print(a%b+int(a/b))

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
c = ar.index(1)
count = 0
count += c // (b - 1)
if c % (b - 1) != 0:
    count += 1
count += (a - 1 - c) // (b - 1)
if (a - 1 - c) % (b - 1) != 0:
    count += 1
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
a_list = list(map(int,input().split()))
base = a_list.index(1)
left = base
Left = 0
right = N-base-1
Right = 0
eraser = K-1


if left%eraser==0:
        Left=left//eraser
else:
        Left=left//eraser+1

if right%eraser==0:
        Right=right//eraser
else:
        Right=right//eraser+1

print(Left+Right)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(n//k+1)

Submission status: Wrong Answer

Solution code:
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
res = 1
print 1 + (N - K) / (K - 1) if N - K >= K - 1 else 1

Submission status: Wrong Answer

Solution code:
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
res = 1
print 1 + (N - K) / (K - 1)

Submission status: Wrong Answer

Solution code:
import numpy
N, K = map(int, raw_input().split())
A = numpy.array(map(int, raw_input().split()))
argmin_A = numpy.where(A == A.min())[0]
if argmin_A[0] != 0:
    argmin_A = numpy.insert(argmin_A, 0, 0)
if argmin_A[-1] != N - 1:
    argmin_A = numpy.append(argmin_A, N - 1)

res = 0
rest = 0
for s, e in zip(argmin_A[:-1], argmin_A[1:]):
    if e - s == 1:
        rest += 1
        if rest >= K:
            res += 1
            rest = 0
        continue
    width = e - s - rest
    rest = width % (K - 1)
    res += width / (K - 1)
if rest > 0:
    res += 1
print res

Submission status: Wrong Answer

Solution code:
import numpy
N, K = map(int, raw_input().split())
A = numpy.array(map(int, raw_input().split()))
argmin_A = numpy.where(A == A.min())[0]
if argmin_A[0] != 0:
    argmin_A = numpy.insert(argmin_A, 0, 0)
if argmin_A[-1] != N - 1:
    argmin_A = numpy.append(argmin_A, N - 1)

res = 0
rest = 0
for s, e in zip(argmin_A[:-1], argmin_A[1:]):
    if e - s == 0:
        continue
    width = e - s - rest
    rest = width % (K - 1)
    res += width / (K - 1)
if rest > 0:
    res += 1
print res

Submission status: Wrong Answer

Solution code:
import numpy
N, K = map(int, raw_input().split())
A = numpy.array(map(int, raw_input().split()))
argmin_A = numpy.where(A == A.min())[0]
if argmin_A[0] != 0:
    argmin_A = numpy.insert(argmin_A, 0, 0)
if argmin_A[-1] != N - 1:
    argmin_A = numpy.append(argmin_A, N - 1)

res = 0
rest = 0
for s, e in zip(argmin_A[:-1], argmin_A[1:]):
    width = e - s - rest
    rest = width % (K - 1)
    res += width / (K - 1)
if rest > 0:
    res += 1
print res

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
i=1
if n % k ==0:
  print(n//k)
  exit()
else:
  while k+(k-1)*i< n:
    i+=1
print(1+i)

Submission status: Wrong Answer

Solution code:
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
mi = a.index(min(a))
c = n//(k-1)
if n%(k-1) > 1:
  c += 1
print(c)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N % K == 0:
    print(round(N/K))
else:
    print(round(N/K)+1)

Submission status: Wrong Answer

Solution code:
import math
def main():
    line_input = input().split()
    n = int(line_input[0])
    k = int(line_input[1])
    nums = input().split()
    for i in range(n):
        nums[i] = int(nums[i])
        if nums[i] == 1:
            index_1 = i

    if index_1 + 1 <= k or index_1 + 1 >= n - k:
        print(get_if_side(n, k))
        return
    else:
        before = nums[0:index_1 + 1]
        before = len(before)
        after = nums[index_1:n]
        after = len(after)
        print(get_if_side(before, k) + get_if_side(after, k))
        return

def get_if_side(n, k):
    return math.ceil((n - 1) / (k - 1))

main()

Submission status: Wrong Answer

Solution code:
import math
def main():
    line_input = input().split()
    n = int(line_input[0])
    k = int(line_input[1])
    nums = input().split()
    for i in range(n):
        nums[i] = int(nums[i])
        if nums[i] == 1:
            index_1 = i
    before = nums[0:index_1 + 1]
    before = len(before)
    after = nums[index_1: n]
    after = len(after)
    if index_1 + 1 <= k or index_1 + 1 >= n - k:
        print(get_if_side(n, k))
        return
    else:
        print(get_if_side(before, k) + get_if_side(after, k))
        return

def get_if_side(n, k):
    return math.ceil((n - 1) / (k - 1))

main()

Submission status: Wrong Answer

Solution code:
import math
def main():
    line_input = input().split()
    n = int(line_input[0])
    k = int(line_input[1])
    nums = input().split()
    for i in range(n):
        nums[i] = int(nums[i])
        if nums[i] == 1:
            index_1 = i

    if index_1 + 1 <= k or index_1 + 1 >= n - k:
        print(math.ceil((n - 1) / (k - 1)))
        return
    else:
        print(math.ceil((index_1) / (k - 1)) + math.ceil((n - index_1 -1) / (k - 1)))
        return
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
fin = sys.stdin.readline
from math import ceil

N, K = [int(elem) for elem in fin().split()]
A_list = [int(elem) for elem in fin().split()]

pos_1 = A_list.index(1)
num_left = pos_1
num_right = N - pos_1 - 1

print(ceil(num_left / (K - 1)) + ceil(num_right / (K - 1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

idx = a.index(1)

if idx < (n//2):
    a = idx//(k-1)
else:
    a = (n-idx-1)//(k-1)

m = n - k - (k-1)*a

if m // (k-1):
    b = m//(k-1)+1
else:
    b = m//(k-1)

print(a+1+b)

Submission status: Wrong Answer

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

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

idx = a.index(1)

a = idx//(k-1)
m = n - k - (k-1)*a
if m // (k-1):
    b = m//(k-1)+1
else:
    b = m//(k-1)

print(a+1+b)

Submission status: Wrong Answer

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

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

if n % (k-1):
    print(n//(k-1)+1)
else:
    print(n//(k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

minNum = min(A)

removedLen = len( [a for a in A if a != minNum ] )

import math

ans = math.ceil( removedLen/2) 

print(ans)