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(X) for X in input().split())
A  = [int(X) for X in input().split()]
OI = A.index(1)
L = (OI+(K-2))//(K-1)
R = ((N-OI-1)+(K-2))//(K-1)
print(L+R)

Submission status: Wrong Answer

Solution code:
N,K = (int(X) for X in input().split())
A  = [int(X) for X in input().split()]
OI = A.index(1)
if OI==0 or OI==(N-1):
    print(N//(K-1))
else:
    L = max(1,(OI+1)//(K-1))
    R = max(1,(N-OI)//(K-1))
    print(L+R)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    if n <= k:
        print(1)
        sys.exit()
    else:
        pos = a.index(1)
        if pos == 0 or pos == n - 1:
            print(ceil(n / (k - 1)))
        else:
            mae = ceil(pos / (k - 1))
            pos = mae * (k - 1) + 1
            ushiro = ceil((n - 1 - pos) / (k - 1))
            r = mae + ushiro
            print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    if n <= k:
        print(1)
        sys.exit()
    else:
        pos = a.index(1)
        if pos == 0 or pos == n - 1:
            mae = ceil(pos / (k - 1))
            ushiro = ceil((n - 1 - pos) / (k - 1))
            r = mae + ushiro
            print(r)
        else:
            mae = ceil(pos / (k - 1))
            pos = mae * (k - 1) + 1
            ushiro = ceil((n - 1 - pos) / (k - 1))
            r = mae + ushiro
            print(r)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    if n <= k:
        print(1)
        sys.exit()
    pos = a.index(1)
    mae = ceil(pos / (k - 1))
    ushiro = ceil((n - 1 - pos) / (k - 1))
    r = mae + ushiro
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil
def main():
    n, k, *a = map(int, read().split())
    pos = a.index(1)
    mae = ceil(pos / (k - 1))
    ushiro = ceil((n - 1 - pos) / (k - 1))
    r = mae + ushiro
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int,input().split())
l = list(map(int,input().split()))
tag = l.index(1)

print(math.ceil((N-1-tag)/(K-1))+math.ceil(tag/(K-1)))

Submission status: Wrong Answer

Solution code:
import math
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        ind = i
        break
left = ind + 1
right = N - ind
ans = 0
if left:
    temp = K
    while(1):
        ans += 1
        if temp >= left:
            break
        temp += K - 1
if right:
    temp = K
    while(1):
        ans += 1
        if temp >= right:
            break
        temp += K - 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        ind = i
        break
left = ind
right = N - ind - 1
ans = 0
if left:
    temp = K - 1
    while(1):
        ans += 1
        if temp >= left:
            break
        temp += K - 1
if right:
    temp = K - 1
    while(1):
        ans += 1
        if temp >= right:
            break
        temp += K - 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        ind = i
        break
left = ind
right = N - ind - 1
ans = math.ceil(left / (K - 1)) + math.ceil(right / (K - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N, K = list(map(int,input().split()))
A = list(map(int,input().split()))
for i in range(N):
    if A[i] == 1:
        ind = i
        break
left = ind
right = N - ind - 1
ans = math.ceil(left / K) + math.ceil(right / K)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# スペース区切りの整数の入力
n, k = map(int, input().split())
#配列の入力
data = list(map(int, input().split()))
min = data.index(1)
ret = 0
a = len(data[:min])-1
b = len(data[min:])-1
#print(a)
#print(b)

if a > 0:
    ret += -(-a // (k-1))
if b > 0:
    ret += -(-b // (k-1))

print(ret)

Submission status: Wrong Answer

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

n = A.index(1)
ans = ((n+1) // (K-1)) + ((N-n) // (K-1))
print(ans)

Submission status: Wrong Answer

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

n = A.index(1)
ans = (n // (K-1)) + ((N-n) // (K-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# C - Minimization

N, K = map(int, input().split())
A = list(int(a) for a in input().split())
ans = 0

idx1 = A.index(1)
ans += (idx1+(K-2)) // (K-1)
ans += ((N-1-idx1)+(K-2)) // (K-1)

print(ans)

Submission status: Wrong Answer

Solution code:
# C - Minimization

N, K = map(int, input().split())
A = list(int(a) for a in input().split())
ans = 0

idx1 = A.index(1)
ans += idx1 // (K-1)
ans += (N-idx1) // (K-1)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import ceil
n,m = map(int, input().split())
a = list(map(int, input().split()))

t = a.index(1)
print(ceil(t/2) + ceil((n-1-t)/2))

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=a.index(min(a))
print(math.ceil(b/(k-1))+math.ceil((n-b-1)/(k-1)))

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    readline()

    q, r = divmod(N, K - 1)
    if r in (0, 1):
        ans = q
    else:
        ans = q + 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    readline()

    ans = ceil(N / (K - 1))
    if N % (K - 1) == 1:
        ans -= 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    N, K = in_nn()
    A = in_nl()

    ind = A.index(1)
    rlen = N - ind
    llen = ind + 1

    ans = ceil(rlen / (K - 1))
    ans += ceil(llen / (K - 1))
    if rlen % (K - 1) == 1:
        ans -= 1
    if llen % (K - 1) == 1:
        ans -= 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int,input().split())
input()
print(int(math.ceil((n - 1)//(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:
n, k = map(int,input().split())
print(n//(k-1) + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

def solve():
    cnt = (N - 1) // (K - 1) + 1
    if N == K:
        cnt = (N - 1) // (K - 1)
    print(cnt)

if __name__ == "__main__":
    N,K = list(map(int, input().split()))    
    a = list(map(int, input().split()))
    solve()

Submission status: Wrong Answer

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

now=A.index(1)


now_l=now
now_r=now
ans=0
while now_l>0:
    now_l-=K-1
    ans+=1
while now_r<N-1:
    now_r+=K-1
    ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N,K = I()
A = l()
i = A.index(1)
print(math.ceil(i/(K-1))+math.ceil((N-i-1)/(K-1)))

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10**9)
mod = 10**9+7

N,K = I()
A = l()
m = min(A)
start = 0
ans = 0
for i in range(N):
    if A[i] == m:
        ans += math.ceil((i-start)/(K-1))
        start = i+1
ans += math.ceil((N-start)/(K-1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

m = min(lis)

if n == k:
    print(1)
elif lis[0] == m or lis[n-1] == m:
    print(math.ceil(n/(k-1))-1)
else:
    print(math.ceil(n/(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)
else:
    print(math.ceil(n/(k-1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def func(n, k):
    """
    n個のものをk個ずつ重なりありでとる回数
    """
    if n == 1: return 0
    if n <= k: return 1
    if (n - k) % (k - 1) == 0: return 1 + (n - k) // (k - 1)
    return 1 + (n - k) // (k - 1) + 1

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    place = 0
    for i in range(N):
        if A[i] == 1:
            place = i
            break
    ans1 = func(place + 1, K)
    ans2 = func(N - place, K)
    print(ans1 + ans2)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
n, k  = [int(i) for i in input().split()]
nums = [int(i) for i in input().split()]

if n == k:
    print(1)
else:
    print(math.ceil(n/(k-1)))

Submission status: Wrong Answer

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

print(n//(k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = []
    for x in range(1, N+1):
        if x > (N-1)/(K-1) and x <= (N+K-1)/(K-1):
            ans.append(x)
    print(min(ans))
main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = []
    for x in range(1, N+1):
        if x > (N-1-K)/(K-1) and x <= (N-1)/(K-1):
            ans.append(x)
    print(min(ans))
main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = []
    for x in range(1, N+1):
        if x > (N-K)/(K-1) and x <= N/(K-1):
            ans.append(x)
    print(min(ans))
main()

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int, input().split()))
in_1 = A.index(1)
counter = 0
left,right = in_1,in_1

if N == K:
    print("1")
else:
    while True:
        if left < K-1 and left != 0:
            counter +=1
            left = 0
        elif left == 0:
            pass
        elif left >= K-1:
            counter += 1
            left -= K-1

        if right > N-K and right != N-1:
            counter += 1
            right = N-1
        elif right == N-1:
            pass
        elif right <= N-K:
            counter += 1
            right += K-1

        if left == 0 and right == N-1:
            break

    print(counter)

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
n=list(map(int,input().split()))
if a==b:
    print(1)
    exit()
m=n.index(min(n))
o=len(n[:m-1])
p=len(n[m+2:-1])
ans=(o//(b-1))+(min(o%(b-1),1))+(p//(b-1))+(min(p%(b-1),1))
print(ans+1)

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int, input().split()))
in_1 = A.index(1)
counter = 0
left,right = in_1,in_1

while True:
    if left < K-1 and left != 0:
        counter +=1
        left = 0
    elif left == 0:
        pass
    elif left >= K-1:
        counter += 1
        left -= K-1

    if right > N-K and right != N-1:
        counter += 1
        right = N-1
    elif right == N-1:
        pass
    elif right <= N-K:
        counter += 1
        right += K-1

    if left == 0 and right == N-1:
        break

print(counter)

Submission status: Wrong Answer

Solution code:
import math

def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    
    i = A.index(1)
    before = len(A[:i])
    after = len(A[i+1:])
    
    return math.ceil(before / (M - 1)) + math.ceil(after / (M - 1))

print(solve())

Submission status: Wrong Answer

Solution code:
import math


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

    if len(A) <= K:
        print(1)
        return

    min_index = A.index(1)

    before = len(A[min_index:])
    after = len(A[min_index + 1:])
    ans = math.ceil(before / K) + math.ceil(after / K)

    print(ans)


resolve()

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:
import sys
input = sys.stdin.readline

def main():
	N,K=map(int,input().split())
	A=list(map(int,input().split()))
	num=0
	ans=0
	for i in range(N):
		if A[i]==1:
			num=i
			break
	if i==0:
		ans=(N-1+(K-1)-1)//(K-1)
		print(ans)
	else:
		ans+=(num+(K-1)-1)//(K-1)
		ans+=(N-num+(K-1)-1)//(K-1)
		print(ans)
if __name__=='__main__':
	main()

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n,k = readInt()
    a = readInt()
    l = -1
    for i in range(n):
        if a[i]==1:
            l = i
            break
    ans = 0
    if l:
        ans += (l + k - 2) // (k - 1)
    r = n - l
    if r:
        ans += (r + k - 2) // (k - 1)
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n,k = readInt()
    a = readInt()
    l = -1
    for i in range(n):
        if a[i]==1:
            l = i
            break
    ans = 0
    if l:
        ans += max(l // (k - 1),1)
    r = n - l
    if r:
        ans += max(r // (k - 1),1)
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n,k = readInt()
    a = readInt()
    ans = n // (k - 1)
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import ceil

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

# check
if N == K:
    print(1)
else:
    min_idx = A.index(1)

    if min_idx == 0:
        r_cnt = 0
    else:
        r_cnt = ceil(len(A[:min_idx]) / (K - 1))
        
    if len(A[:min_idx + 1]) < K:
        min_idx = K - 1

    if min_idx == N - 1:
        l_cnt = 0
    else:
        l_cnt = ceil(len(A[min_idx + 1:]) / (K - 1))

    print(r_cnt + l_cnt)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

# check
if N == K:
    print(1)
else:
    min_idx = A.index(1)

    if min_idx == 0:
        r_cnt = 0
    else:
        r_cnt = ceil(len(A[:min_idx]) / (K - 1))

    if min_idx == N - 1:
        l_cnt = 0
    else:
        l_cnt = ceil(len(A[min_idx + 1:]) / (K - 1))

    print(r_cnt + l_cnt)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

# check
if N == K:
    print(1)
else:
    min_idx = A.index(1)

    if min_idx == 0:
        r_cnt = 0
    else:
        r_cnt = ceil(min_idx / (K - 1))

    if min_idx == N - 1:
        l_cnt = 0
    else:
        l_cnt = ceil((N - min_idx - 1) / (K - 1))

    print(r_cnt + l_cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
As = list(map(int, input().split()))
idx = As.index(1)
nf = n-1 - idx
nb = idx
ans = 0
while nf > 0:
  nf -= k-1
  ans += 1
while nb > 0:
  nb -= 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 k >= n:
    print(1)
    exit()
s = a.index(1)
left = s
right = n - (s + 1)
if left < k-1:
    right -= ((k-1) - left)
if right < k-1:
    left -= ((k-1) - right)
print(math.ceil(left / (k-1)) + math.ceil(right / (k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
As = list(map(int, input().split()))
ind = As.index(1)
f=0
b=0
nf = 0
nb = 0
while f < n-ind:
  nf += 1
  f += k-1
while b < ind:
  nb +=1
  b += k-1
print(nf + nb)

Submission status: Wrong Answer

Solution code:
import math


def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    print(math.ceil((n -1) // (k - 1)))

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(input().split())
A_lis = [int(A[i]) for i in range(N)]
index = A_lis.index(1)

if N == K:
    print(1)
else:
    left = math.ceil(index / (K-1))
    leftamari = index % (K-1)
    right = math.ceil(max(0, N - K - index + leftamari) / (K-1))
    print(left + right)

Submission status: Wrong Answer

Solution code:
import math

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

index = A_lis.index(1)
if N == K:
    print(1)
else:
    print(math.ceil(index / (K-1)) + math.ceil((N-index-1 - (index % (K-1))) / (K-1)))

Submission status: Wrong Answer

Solution code:
import math

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

index = A_lis.index(1)

if N == K:
    print(1)
else:
    print(math.ceil(index / (K-1)) + math.ceil((N-index-1) / (K-1)))

Submission status: Wrong Answer

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n,k = map(int, input().split())
    a_list = list(map(int, input().split()))
    if n == k:
        print(1)
    else:
        print(ceil(n/k) + 1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    n,k = map(int, input().split())
    a_list = list(map(int, input().split()))
    if n == k:
        print(1)
    else:
        print((n//k) + 1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
s = list(map(int, input().split()))
n=s[0]
k=s[1]-1
s = list(map(int, input().split()))
ind=s.index(1)
print(math.ceil(ind/k)+math.ceil((n-ind-1)/k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

mae = arr.index(1)
usiro = len(arr)-1-arr.index(1)
ans = math.ceil(mae/(K-1))+math.ceil(usiro/(K-1))

if arr[0] ==1 or arr[-1] ==1:
    print(ans-1)
    exit()
else:
    print(ans)

Submission status: Wrong Answer

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

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

mae = arr.index(1)
usiro = len(arr)-1-arr.index(1)
ans = math.ceil(mae/(K-1))+math.ceil(usiro/(K-1))

if mae ==0 or mae ==N-1:
    print(ans-1)
    exit()
else:
    print(ans)

Submission status: Wrong Answer

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

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

mae = arr.index(1)
usiro = len(arr)-1-arr.index(1)
print(math.ceil(mae/(K-1))+math.ceil(usiro/(K-1)))

Submission status: Wrong Answer

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
#======================================================#
def main():
    n, k = MII()
    aa = MII()
    print((-(-n//(k-1))) if n > 3 else 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n,k=map(int,input().split())
a=[int(x) for x in input().split()]
print(math.ceil(n/k))

Submission status: Wrong Answer

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

# 1の場所を探す
pos = A.index(1)

count = 0
range_s = pos - 1  # 1でない前方位置はここまで
range_e = pos + 1  # 1でない後方位置はここから
while range_s >= 0:  # 先頭まで1にする
    range_s -= K-1
    count += 1
while range_e < N:  # 末尾まで1にする
    range_e += K-1
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n,k=[int(x) for x in input().rstrip().split()]
a=[int(x) for x in input().rstrip().split()]
now=0
ans=0
if n==k:
  print(1)
else:
  while(0<n):
    n-=k
    n+=1
    ans+=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
right = N-1-index
left = index

def judge(value,k,ans):
    if value%k == 0:
        return  value//k
    else:
        return  value//k+1

ans += judge(right,K-1,ans)
ans += judge(left,K-1,ans)


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 = 1
right = 0
left = 0

if (N-1)//2 < index:
    right = N-1-index
    left = index
else:
    left = index
    right = N-1-index


if right == 0:
    left -= K-1
    if left%(K-1) == 0:
        ans += left//(K-1)
    else:
        ans += left//(K-1)+1
elif left == 0:
    right -= K-1
    if right%(K-1) == 0:
        ans += right//(K-1)
    else:
        ans += right//(K-1)+1
elif right%(K-1) == 0:
    right -= K-1
    if left%(K-1) == 0:
        ans += right//(K-1)+left//(K-1)
    else:
        ans += right//(K-1)+left//(K-1)+1
elif left%(K-1) == 0:
    left -= K-1
    if right%(K-1) == 0:
        ans += right//(K-1)+left//(K-1)
    else:
        ans += right//(K-1)+left//(K-1)+1
else:
    left -= K-1
    ans += right//(K-1)+left//(K-1)+2

print(ans)

Submission status: Wrong Answer

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

index = A.index(1)
cnt = 1

right = 0
left = 0

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

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

print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N, K = MAP()
A = LIST()

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