Problem:


Score : 300 points

Problem Statement

There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.

On this sequence, Snuke can perform the following operation:

Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.

Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.

Constraints

2 \leq K \leq N \leq 100000

A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

Print the minimum number of operations required.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

One optimal strategy is as follows:

In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.

In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4



Sample input:
4 3
2 3 1 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
m = A.index(1)
print((m + 1) // (K - 1) + (N - m) // (K - 1))

Submission status: Wrong Answer

Solution code:
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
m = A.index(1)
print(2 + (N - 1 - m) // (K - 1) + (m - 1) // (K - 1))

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_idx = i
        break
ans = 10**9
for i in range(k):
    ans_cur = 1
    l = min_idx - i
    r = l + (k-1)
    if l > 0:
        ans_cur += l//(k-1)+1 if l%(k-1) > 0 else l//(k-1)
    if r < n-1:
        ans_cur += (n-1-r)//(k-1)+1 if (n-1-r)%(k-1) > 0 else (n-1-r)//(k-1)
        ans = min(ans, ans_cur)
print(ans)

Submission status: Wrong Answer

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

for i in range(N) :
    if L[i] == 1 :
        p = i
        break

if (p == 0) or (p == N-1) :
    if N % K == 0 :
        ans = N//K
    else :
        ans = N//K + 1
else :
    flag = 0
    ans = 0
    while flag == 0 :
        if N <= 0 :
            flag = 1
        else :
            N -= K
            ans += 1
            N += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i = A.index(1)
x = 0
t = i
x += (t +  (K-1) - 1) // (K - 1)
t = N  -  (i + 1)
x += (t +  (K-1) - 1) // (K - 1)
print(x)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
k-=1
l=chk
r=n-(chk+1)
t1=k-l%k
t2=k-r%k
print(min(((l+k-1)//k)+((r+k-1)//k),((l-t2)//k)+((r+k-1)//k), ((l+k-1)//k)+((r-t1)//k)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
k-=1
l=chk
r=n-(chk+1)
t1=l%k
t2=r%k
print(min(((l+k-1)//k)+(r//k),((l-t2)//k)+(r//k), (l//k)+((r-t1)//k)))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk
r=n-(chk+1)
t1=l%(k-1)
t2=r%(k-1)
print(min(l//(k-1)+r//(k-1),((l-t2)//(k-1))+(r//(k-1)), (l//(k-1))+((r-t1)//(k-1))))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk+k-2
r=n-(chk+1)+k-2
t1=l%(k-1)
t2=r%(k-1)
print(min(l//(k-1)+r//(k-1),((l-t2)//(k-1))+(r//(k-1)), (l//(k-1))+((r-t1)//(k-1))))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk+k-2
r=n-(chk+1)+k-2
t1=(k%(k-1))-(l%(k-1))
t2=(k%(k-1))-(r%(k-1))
print(min(l//(k-1)+r//(k-1),((l-t2)//(k-1)+r//(k-1)), (l//(k-1)+(r-t1)//(k-1))))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk+k-2
r=n-(chk+1)+k-2
t1=k-(l%(k-1))
t2=k-(r%(k-1))
print(min(l//(k-1)+r//(k-1),((l-t2)//(k-1)+r//(k-1)), (l//(k-1)+(r-t1)//(k-1))))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk+k-2
r=n-(chk+1)+k-2
print(l//(k-1)+r//(k-1))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
print(chk//(k-1)+(n-chk+k-2)//(k-1))

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
print(chk//(k-1)+(n-chk-1)//(k-1))

Submission status: Wrong Answer

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

i1 = A.index(1)
d1, m1 = divmod(i1, K - 1)
d2, m2 = divmod(N - i1 - 1, K - 1)

print(d1 + d2 + (m1 != 0) + (m2 != 0))

Submission status: Wrong Answer

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

# 1のある場所で決まる
pos1 = a.index(1) + 1
front = pos1 - 1
back = n - front - 1

if front % (k-1) == 0:
    resf = front // (k-1)
else:
    resf = (front // (k-1)) + 1

if back % (k-1) == 0:
    resb = back // (k-1)
else:
    resb = (back // (k-1)) + 1

print(resf + resb)

Submission status: Wrong Answer

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

A=list(map(int,input().split()))
if(n<=k):
    print(1)
    sys.exit(0)


ind=A.index(1)
if(n-1<ind+k-1):
    ind=n-1
if(ind-k+1<0):
    ind=0
tmp=ind
count=0



while(1):
    if(tmp<=0):
        break
    else:
        tmp-=k-1
        count+=1

tmp=ind
while(1):
    if(n-1<=tmp):
        break
    else:
        tmp+=k-1
        count+=1

print(count)

Submission status: Wrong Answer

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

A=list(map(int,input().split()))
if(n<=k):
    print(1)
    sys.exit(0)


ind=A.index(1)
tmp=ind
count=0
while(1):
    if(tmp<=0):
        break
    else:
        tmp-=k-1
        count+=1

tmp=ind
while(1):
    if(n-1<=tmp):
        break
    else:
        tmp+=k-1
        count+=1

print(count)

Submission status: Wrong Answer

Solution code:
import math

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

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

index = A.index(1)
ans = 0
ans += math.ceil(index / (K - 1))
ans += math.ceil((N - index - 1) / (K - 1))

temp = index % (K - 1) + (N - index - 1) % (K - 1)

if temp == 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()))

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

index = A.index(1)
ans = 0
ans += math.ceil(index / (K - 1))
ans += math.ceil((N - index - 1) / (K - 1))

temp = index % (K - 1) + (N - index - 1) % (K - 1)

if index != 0 and (N - index - 1) != 0 and temp == 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()))

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

index = A.index(1)
ans = 0
ans += math.ceil(index / (K - 1))
ans += math.ceil((N - index - 1) / (K - 1))

temp = index % (K - 1) + (N - index - 1) % (K - 1)

if index != 0 and (N - index - 1) != 0 and  temp >= 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()))

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

index = A.index(1)
ans = 0
ans += math.ceil(index / (K - 1))
ans += math.ceil((N - index - 1) / (K - 1))

if index != 0 and (N - index - 1) != 0 and index % (K - 1) + (N - index - 1) % (K - 1) == 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()))

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

index = A.index(1)
ans = 0
ans += math.ceil(index / (K - 1))
ans += math.ceil((N - index - 1) / (K - 1))

if index != 0 and (N - index - 1) != 0 and (index % (K - 1) + (N - index - 1)) % (K - 1) == 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()))

index = A.index(1)
ans = 0
ans += math.ceil(index / (K - 1))
ans += math.ceil((N - index - 1) / (K - 1))

if index != 0 and (N - index - 1) != 0 and index % (K - 1) + (N - index - 1) % (K - 1) == 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()))

index = A.index(1)
ans = 0
ans += math.ceil(index / (K - 1))
ans += math.ceil((N - index - 1) / (K - 1))

if index % (K - 1) + (N - index - 1) % (K - 1) == 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()))

index = A.index(1)
ans = 0
if index > 0:
    ans += math.ceil(index / (K - 1))

if index < N - 1:
    ans += math.ceil((N - index - 1) / (K - 1))

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

index = A.index(1)
ans = 0
if index > 0:
    ans += math.ceil((index - 1) / (K - 1))

if index < N - 1:
    ans += math.ceil((N - index - 1) / (K - 1))

print(ans)

Submission status: Wrong Answer

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

index = A.index(1)
ans = 0
if index > 0:
    ans += (index) // (K - 1)

if index < N - 1:
    ans += (N - index) // (K - 1)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
(n, k) = map(int, input().split())
_ = input()
count = n // (k - 1)
if n % 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((N - K + 1) // (K - 1) + 1)

Submission status: Wrong Answer

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

pole = 0
for i in range(n):
    if a[i] == 1:
        pole = i

l = pole
r = n - 1 - pole

for i in range(k - 1):
    if l % (k - 1) == i:
        if k - i - 1 >= r:
            if l == 0:
                print(0)
            else:
                print(1 + int(l / (k - 1)))
        else:
            if l == 0:
                print(1 + int((r - k + i + 1) / (k - 1)))
            else:
                print(1 + int(l / (k - 1)) + 1 + int((r - k + i + 1) / (k - 1)))

Submission status: Wrong Answer

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

pole = 0
for i in range(n):
    if a[i] == 1:
        pole = i

l = pole
r = n - 1 - pole

for i in range(k - 1):
    if l % (k - 1) == i:
        if k - i - 1 > r:
            if l == 0:
                print(0)
            else:
                print(1 + int(l / (k - 1)))
        else:
            if l == 0:
                print(1 + int((r - k + i + 1) / (k - 1)))
            else:
                print(1 + int(l / (k - 1)) + 1 + int((r - k + i + 1) / (k - 1)))

Submission status: Wrong Answer

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

pole = 0
for i in range(n):
    if a[i] == 1:
        pole = i

l = pole + 1
r = n - pole

if l % 2 == 1:
    print(int(l / 2) + int(r / 2))
else:
    print(int(l / 2) + int((r + 1)/ 2) - 1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n, k = [int(x) for x in input().split()]
alist = [int(x) for x in input().split()]
l = alist.index(1) + 1
ans = 0
if (l-1) % (k-1) != 0 and l != 1:
    ans += 1
if (n-l) % (k-1) != 0 and (n-l+1) != 1:
    ans += 1
ans += (int((l-1) / (k-1)) + int((n-l) / (k-1)))
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
place = a.index(1)
ans = 0
if place == 0:
    pass
elif place % (k - 1) == 0:
    ans += place // (k-1)
else:
    ans += (place // (k - 1)) + 1
if n - place - 1 == 0:
    pass
elif (n - place - 1) % (k - 1) == 0:
    ans += (n - place - 1) // (k - 1)
else:
    ans += ((n - place - 1) // (k - 1)) + 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=list(map(int, input().split()))
Q=0
for i,x in enumerate(input().split()):
    if x =='1':
        Q=i+1
        break
K-=1
ans1=(Q-1)//K+((Q-1)%K>0)+(N-Q)//K+((N-Q)%K>0)
ans2=max(0,(Q-2))//K+(max(0,(Q-2))%K>0)+max((N-Q-1),0)//K+(max((N-Q-1),0)%K>0)+1
print(min(ans1,ans2))

Submission status: Wrong Answer

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

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

count = 0
ahead = A.index(1)
if ahead % (K-1) == 0:
    ahead = int(ahead / (K-1))
else:
    ahead = int(ahead / (K-1)) + 1
    count = ahead % (K-1)
back = N - A.index(1) - 1
if back % (K-1) == 0:
    back = int(back / (K-1))
else:
    back = int((back - count) / (K-1)) + 1

print(ahead + back)

Submission status: Wrong Answer

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

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

ahead = A.index(1)
if ahead % (K-1) == 0:
    ahead = int(ahead / (K-1))
else:
    ahead = int(ahead / (K-1)) + 1
back = N - A.index(1) - 1
if back % (K-1) == 0:
    back = int(back / (K-1))
else:
    back = int(back / (K-1)) + 1

print(ahead + back)

Submission status: Wrong Answer

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

ahead = A.index(1)
if ahead % (K-1) == 0:
    ahead = int(ahead / (K-1))
else:
    ahead = int(ahead / (K-1)) + 1
back = N - A.index(1) - 1
if back % (K-1) == 0:
    back = int(back / (K-1))
else:
    back = int(back / (K-1)) + 1

print(ahead + back)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
print(int(A.index(1)/(K-1)+(N-A.index(1))/(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 = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]

print(n // (k - 1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    one = seq.index(1)
    counter = 0
    left, right = one, one
    while True:
        if left > 0:
            counter += 1
        if right < len(seq) - 1:
            counter += 1

        left = max(0, left-K+1)
        right = min(len(seq)-1, right+K-1)
        if left == 0 and right == len(seq) - 1:
            break

    print(counter)

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
I = A.index(min(A))
L = -(-I // (K-1))
R = -(-(N - I - 1) // (K-1))
print(L + R)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
w = 0
for i in range(N):
    if A[i] == 1:
        w = i
        break
a = int((w + 1) / (K - 1))
b = int((N - w) / (K - 1))
print(a + b)

Submission status: Wrong Answer

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

list_a = []
for part in input().split():
    list_a.append(int(part))

print(N // (K - 1))

Submission status: Wrong Answer

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

left = len(A[0:min_in])

right = len(A[min_in+1:])
#print(left,  right)
if N ==K:
    ans = 1
    
else:
    if (min(left, right) + 1) < K:
        ans += 1
        tuyoi = N-K
        
        ans += tuyoi//K
        
        if tuyoi % K !=0:
            ans +=1
    
    else:
        if left != 0:
            ans += left//(K-1)
            
            if left%(K-1) != 0:
                ans += 1
        
        if right != 0:
            ans += right//(K-1)
            
            if right%(K-1) != 0:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stderr
from functools import reduce
from operator import add
from math import ceil
def f(): return [int(i) for i in input().split()]
def debug(*x): stderr.write(reduce(add,repr(x)).strip("()\',")+'\n')

n,k = f()
a = f()

minarg = a.index(1) + 1
ans = 0
ans += ceil((minarg - 1) / (k - 1))
if ans != n:
    ans += ceil((n - minarg) / (k - 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(n//(k-1))

Submission status: Wrong Answer

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

l_num = n - index_1 - 1
r_num = n - l_num - 1

l_count = - (- l_num // (k - 1))
r_count = - (- r_num // (k - 1))

l_rem = l_num % (k - 1)
r_rem = r_num % (k - 1)

x = 0
if (l_rem * r_rem != 0) and (l_rem + r_count + 1 <= k):
    x = -1

# print(l_num, l_count, l_rem, "|", r_num, r_count, r_rem)

print(l_count + r_count + x)

Submission status: Wrong Answer

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

l_num = n - index_1 - 1
r_num = n - l_num - 1

l_count = - (- l_num // (k - 1))
r_count = - (- r_num // (k - 1))

l_rem = l_num % (k - 1)
r_rem = r_num % (k - 1)

x = 0
if (l_rem * r_rem != 0) and (l_rem + r_count + 1 <= k):
    x = -1

print(l_count + r_count + x)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
f=a.index(1)
if f==0 or f==n-1:
    print(n//(k-1))
else:
    print(-(-f//(k-1))+(-(-(n-f)//(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:
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
p = a.index(1)

print(math.ceil(p/(k-1)) + math.ceil((n-p-1)/(k-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)

Submission status: Wrong Answer

Solution code:
a = map(int,raw_input().split())
print (a[0]-1)//(a[1]-1)+1

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from math import ceil

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

indexof1 = A.index(1)

left = ceil(indexof1/(k-1))
right = ceil((len(A)-1-indexof1)/(k-1))

print(left+right)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

i = np.argmin(A)

if N != K:
    if i == 0:
        r = int(round((N-i)/(K-1)))
    elif i == N:
        r = int(round((N-i)/(K-1)))
    else:
        r = int(round(i/(K-1)) + round((N-i)/(K-1)))
else:
    r = 1

print(r)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
input()
if K >= N:
    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+N%K)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
def kiriage(a, b): #切り上げ
    return (a + b - 1) // b
i = A.index(1)
left = kiriage(i, K-1)
right = kiriage(N - 1 - i, K - 1)
print(left + right)

Submission status: Wrong Answer

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

i = A.index(1)
print((i + K - 3) //(K - 1) + (N + K - i -3) //(K - 1))

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)
rcount = 0
lcount = 0

if idx != 0:
    lcount = int(math.ceil((idx)/(K-1)))
if idx != N-1:
    rcount = int(math.ceil((N-1-idx)/(K-1)))

answer = rcount + lcount
print(answer)

Submission status: Wrong Answer

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

xs = sorted(xs)

min_ = min(xs)

cur = 0

for l in range(1, 100000):
  try:
    for j in range(xs[cur:].index(min_), k):
      xs[cur+j] = min_
    cur = cur + xs[cur:].index(min_)+k-1
    #print(cur)
    #print(xs)
  except:
    break
#print(xs)
print(l)

Submission status: Wrong Answer

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

m=A.index(1)

le=m
ri=n-m
if le//(k-1)!=0 :
    ri-=(k-1)-le%(k-1)

print(le//(k-1)+ri//(k-1))

Submission status: Wrong Answer

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

m=A.index(1)

le=m
ri=n-m
if le//(k-1)!=0 :
    ri-=le%(k-1)

print(le//(k-1)+ri//(k-1))

Submission status: Wrong Answer

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

m=A.index(1)

print(m//(k-1)+(n-m)//(k-1))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in list(input().split())]
print(round((N-1)/(K-1)+0.5))

Submission status: Wrong Answer

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

print(N//K + bool(N%K))

Submission status: Wrong Answer

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


def f(N, K):
  if N == K:
    return 1
  for i in range(2, N):
    if K > N // i:
      return i
print(f(N,K))

Submission status: Wrong Answer

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

mn = 1#min値を取得
mnix = li.index(1)
mnix0 =mnix #min値の最初のindex
sum = 0 #操作の回数
# k
# li
f=[False]
#左側をまず1へ
while(1):
    if f[0]==True:
        break

    if (mnix+1-k) >0:
        for i in range(mnix+1-k,mnix+1):
            li[i] = mn
        sum +=1
        mnix=li.index(1)
        # print(mnix,li)
    else:
        for i in range(0,k):
            li[i] = mn
        f[0]=True
        sum +=1
# sum
# li
#次に右側を1へ
if (mnix0+1-k) >0:
    #mnix0が右端
    migi = mnix0
if (mnix0+1-k) <=0:
    #k-1が右端
    migi = k-1
# migi

    
f[0]=False
if li[n-1]==1:
    f[0]=True
while(1):
    if f[0]==True:
        break
    if (migi+k-1)>=(n-1):
        for i in range(migi,n):
            li[i] = mn
        sum +=1
        f[0]=True
    else:
        for i in range(migi,migi+k):
            li[i] = mn
        sum +=1
        migi = migi+k-1

 
print(sum)

Submission status: Wrong Answer

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

mn = 1#min値を取得
mnix = li.index(1)
mnix0 =mnix #min値の最初のindex
sum = 0 #操作の回数
# k
# li
f=[False]
#左側をまず1へ
while(1):
    if f[0]==True:
        break

    if (mnix+1-k) >0:
        for i in range(mnix+1-k,mnix+1):
            li[i] = mn
        sum +=1
        mnix=li.index(1)
        # print(mnix,li)
    else:
        for i in range(0,k):
            li[i] = mn
        f[0]=True
        sum +=1

# li
#次に右側を1へ
if (mnix0+1-k) >0:
    #mnix0が右端
    migi = mnix0
if (mnix0+1-k) <=0:
    #k-1が右端
    migi = k-1
# migi

    
f[0]=False
if li[n-1]==1:
    f[0]=True
while(1):
    if f[0]==True:
        break
    if (migi+k-1)>(n-1):
        for i in range(migi,n):
            li[i] = mn
        sum +=1
        f[0]=True
    else:
        for i in range(migi,migi+k):
            li[i] = mn
        sum +=1
        migi = migi+k-1

 
print(sum)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def getMinIndex(Ai):
    return Ai.index(1)

def solve(Ai, K):
    mIndex = getMinIndex(Ai)
    
    rRest = len(Ai) - mIndex - 1
    lRest = mIndex
    ans = 0

    if rRest == lRest:
        rRest -= (K//2)
        lRest -= (K//2)
        ans += 1

    if rRest != 0:
        ans += rRest // (K-1)
        if rRest % (K-1) != 0:
            ans += 1

    if lRest != 0:
        ans += lRest // (K-1)
        if lRest % (K-1) != 0:
            ans += 1
    
    return ans

if __name__ == "__main__":

    N, K = [int(x) for x in input().split()]
    Ai = [int(x) for x in input().split()]
    print(solve(Ai, K))

Submission status: Wrong Answer

Solution code:
# coding: utf-8

def getMinIndex(Ai):
    return Ai.index(1)

def solve(Ai, K):
    mIndex = getMinIndex(Ai)
    
    rRest = len(Ai) - mIndex - 1
    lRest = mIndex
    ans = 0

    if rRest != 0:
        ans += rRest // (K-1)
        if rRest % (K-1) != 0:
            ans += 1

    if lRest != 0:
        ans += lRest // (K-1)
        if lRest % (K-1) != 0:
            ans += 1
    
    return ans

if __name__ == "__main__":

    N, K = [int(x) for x in input().split()]
    Ai = [int(x) for x in input().split()]
    print(solve(Ai, K))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

min_ind = A.index(1)

bh = np.ceil(min_ind / (K-1))
bh_amari = min_ind % (K-1)

min_ind += bh_amari

if min_ind >= N -1:
    ah = 0
else:
    ah = np.ceil((N - 1 - min_ind) / (K-1))

print(int(bh + ah))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

min_ind = A.index(1)

bh = np.ceil(min_ind / (K-1))
bh_amari = min_ind % (K-1)

if min_ind + bh_amari >= N -1:
    ah = 0
else:
    ah = np.ceil((N - (min_ind + bh_amari) - 1) / (K-1))

print(int(bh + ah))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

min_ind = A.index(1)

bh = np.ceil(min_ind / (K-1))
bh_amari = min_ind % (K-1)

if min_ind + bh_amari > N -1:
    ah = 0
else:
    ah = np.ceil((N - (min_ind + bh_amari) - 1) / (K-1))

print(int(bh + ah))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

min_ind = A.index(1)

bh = np.ceil(min_ind / (K-1))
bh_amari = min_ind % (K-1)

ah = np.ceil((N - (min_ind + bh_amari) - 1) / (K-1))

print(int(bh + ah))

Submission status: Wrong Answer

Solution code:
import math

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

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

i = A.index(1)

lt = math.ceil(i // (N[1] - 1))
rt = math.ceil((N[0] - i) // (N[1] - 1))

print(lt + rt)

Submission status: Wrong Answer

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

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

i = A.index(1)

lt = i // (N[1] - 1)
rt = (N[0] - i) // (N[1] - 1)

print(lt + rt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split() ))
math.ceil( (N-1)/(K-1) )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print((N - 1) // (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))

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, input().split())
a = list(map(int, input().split()))
p = a.index(1)

print(((p+1)//(k-1)) + ((n-p)//(k-1)))

Submission status: Wrong Answer

Solution code:
# https://beta.atcoder.jp/contests/abc101/tasks/arc099_a

n, k = list(map(int, input().split()))
nums = list(map(int, input().split()))
location = 0

for i in range(n):
    if nums[i] == 1:
        location = i + 1
        break

# print(len(nums))
from_r = len(nums) - location

from_l = location - 1
# print(from_r)
# print(from_l)

def divided_by(num):
    if num == 0:
        return 0
    elif num == 1:
        return 1
    elif num % 2 == 0:
        return num // 2
    elif num % 2 != 0:
        return num // 2 + 1


r = divided_by(from_r)
l = divided_by(from_l)
print(r + l)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
while N-K+1 >= 0:
    N = N-K+1
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
while N-K+1 >= 0:
    N = N-K+1
    ans += 1
    print(N)
print(ans)

Submission status: Wrong Answer

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

print(int(N/K)+(N % K))

Submission status: Wrong Answer

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

ans = int((n-k)/(k-1)+2)
print(ans)

Submission status: Wrong Answer

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

num = ((N-1)//(K-1))+1

print(num)

Submission status: Wrong Answer

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

if N<=K : num=1
else: num = (N-K)//(K-1)+2

print(num)

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))[:n]
x=a.index(1)
k-=1
print(min([math.ceil((len(a[:x])-i)/k)+math.ceil((len(a[x+1:])-abs(k-i))/k)+i for i in range(0,k+1)]))

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))[:n]
x=a.index(1)
print(min([math.ceil((len(a[:x])-i)/2)+math.ceil((len(a[x+1:])-i)/2)+i for i in[0,1]]))