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

def main():
    num, length = map(int, input().split())
    data = list(map(int, input().split()))

    ind = data.index(1)
    left = ind + 1
    ans = math.ceil((left - 1) / (length - 1))
    ind = (length - 1) * ans
    right = num - ind
    ans += math.ceil(right / (length - 1))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

def main():
    num, length = map(int, input().split())
    data = list(map(int, input().split()))

    ind = data.index(1)
    left = ind + 1
    right = num - ind
    ans = math.ceil((left - 1) / (length - 1)) + math.ceil((right - 1) / (length - 1))
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

argmin_i = a_list.index(1)
if argmin_i < K or argmin_i >= (N-K):
    print(1 + math.ceil((N-K)/(K-1)))
else:
    print(math.ceil((N-argmin_i -1)/(K-1)) + math.ceil((argmin_i)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

Solution code:
import math

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

if N == K:
    print(1)
else:
    argmin_i = a_list.index(1)
    if argmin_i < K or argmin_i >= (N-K):
        print(1 + math.ceil((N-K)/(K-1)))
    else:
        print(math.ceil((N-argmin_i -1)/(K-1)) + math.ceil((argmin_i)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math

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

if N == K:
    print(1)
elif N // 2 < K:
    print(2)
else:
    argmin_i = a_list.index(1)
    if argmin_i < K or argmin_i >= (N-K):
        print(1 + math.ceil((N-K)/(K-1)))
    else:
        print(math.ceil((N-argmin_i -1)/(K-1)) + math.ceil((argmin_i)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math

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

if N == K:
    print(1)
elif N // 2 < K:
    print(2)
else:
    argmin_i = a_list.index(min(a_list))
    if argmin_i < K or argmin_i >= (N-K):
        print(1 + math.ceil((N-K)/(K-1)))
    else:
        print(math.ceil((N-argmin_i)/(K-1)) + math.ceil((1+argmin_i)/(K-1)))

Submission status: Wrong Answer

Solution code:
import math

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

if N == K:
    print(1)
elif N // 2 < K:
    print(2)
else:
    argmin_i = a_list.index(min(a_list))
    if argmin_i < K or argmin_i >= (N-K):
        print(1 + math.ceil((N-K)/(K-1)))
    else:
        print(math.ceil((N-K)/(K-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

def dfs(N,ans):
    if N < 0:
        return ans
    return dfs(N-(K -1),ans+1)

print(dfs(N-K,1))

Submission status: Wrong Answer

Solution code:
def abc101_c():
    n, k = map(int, input().split())
    vs = list(map(int, input().split()))
    
    index = 0
    for i, v in enumerate(vs):
        if v == 1:
            index = i
            break
    count_l = index
    count_r = n - index - 1
    from math import ceil
    return ceil(count_l / (k - 1)) + ceil(count_r / (k - 1))
            
print(abc101_c())

Submission status: Wrong Answer

Solution code:
def abc101_c():
    n, k = map(int, input().split())
    vs = list(map(int, input().split()))
    
    min_v = min(vs)
    cs = []
    c = 0
    for i, v in enumerate(vs):
        if v == min_v:
            if c > 0:
                cs.append(c)
            c = 0
        else:
            c += 1
    else:
        if c > 0:
            cs.append(c)
    from math import ceil
    return sum(ceil(c / (k - 1)) for c in cs)
            
print(abc101_c())

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

min_num = min(x_list)
group_list = []

count = 0
for x in x_list:
  if x == min_num:
    group_list.append(count)
    count = 0
    continue
  count += 1

if x != min_num:
  group_list.append(count)
ans = 0
for count in group_list:
  ans += math.ceil(count / (k - 1))
  
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

min_num = min(x_list)
group_list = []

count = 0
for x in x_list:
  if x == min_num:
    group_list.append(count)
    count = 0
    continue
  count += 1

if x != min_num:
  group_list.append(count)
print(group_list)
ans = 0
for count in group_list:
  ans += math.ceil(count / (k - 1))
  
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

np_list = np.array(x_list)
min_idx = np.argmin(np_list)

if min_idx == 0 or min_idx == n - 1:
  ans = math.ceil((n - min_idx - 1) / (k - 1))
else:
  ans = math.ceil((min_idx) / (k - 1)) + math.ceil((n - min_idx - 1) / (k - 1))

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

np_list = np.array(x_list)
min_idx = np.argmin(np_list)

if min_idx == 0:
  ans = math.ceil((n - min_idx) / k)
elif min_idx == n - 1:
  ans = math.ceil((min_idx + 1) / k)
else:
  ans = math.ceil((min_idx + 1) / k) + math.ceil((n - min_idx + 1) / k)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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


index = a.index(1)

t = index
ans = 0

while t>0:
    t -= k-1
    ans += 1

t = index
while t<n-1:
    t += k-1
    ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
[N,K] = [int(i) for i in 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())
nums = list(map(int,input().split()))
center = nums.index(min(nums))
leftrem = center+1
rightrem = N-center

def g(n,k):
  ii = 0
  while True:
    if k<=(n+(n-1)*ii):
      return ii+1
    ii += 1

if N==K:
  print(1)
else:
  print(g(K,leftrem)+g(K,rightrem))

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
#1の左側と右側
#A[i]=1のとき, 左側のi個の数字を1に変え、右側のN-i-1個の数字を1に変える
#1回の操作でK-1個の数字を1に変えられる
#左側はi // (K-1) + 0or1回の操作で完了右側も同様
one = 0
for i in range(N):
    if A[i] == 1:
        one = i
        break

#one:1が格納してある位置
#K-1個ずつ1を作ることができる
#N//(K-1)回の付近が答え
#1の左側にはone個の数があり右側にはN-one-1個の数
#one%(K-1)=0なら,"1を1に変える"作業は不要->ans=one//(K-1) + {(N-one-1) // (K-1) or (N-one-1) // (K-1) + 1}


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

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
#1の左側と右側
#A[i]=1のとき, 左側のi個の数字を1に変え、右側のN-i-1個の数字を1に変える
#1回の操作でK-1個の数字を1に変えられる
#左側はi // (K-1) + 0or1回の操作で完了右側も同様
one = 0
for i in range(N):
    if A[i] == 1:
        one = i
        break

#one:1が格納してある位置
#K-1個ずつ1を作ることができる
#N//(K-1)回の付近が答え
#1の左側にはone個の数があり右側にはN-one-1個の数
#one%(K-1)=0なら,"1を1に変える"作業は不要->ans=one//(K-1) + {(N-one-1) // (K-1) or (N-one-1) // (K-1) + 1}


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

Submission status: Wrong Answer

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

location_1 = As.index(1)

ans = 0

ans += (location_1 + (K-1)-1) // (K-1)

ans += ((N - location_1 - 1) + (K-1)-1) // (K-1) 

print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int, input().split())
A = input().split()
l = A.index("1")
r = len(A) - l - 1
print(int(math.ceil(l/(K-1))+math.ceil(r/(K-1))))

Submission status: Wrong Answer

Solution code:
import math
N,K=map(int, input().split())
A = input().split()
l = A.index("1")
r = len(A) - l - 1
print(math.ceil(l/(K-1))+math.ceil(r/(K-1)))

Submission status: Wrong Answer

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

a = min(A)

count = 0
answer = 0

A.append(a)
for i in range(N+1):
    if A[i] == a:
        if count != 0:
            answer += math.ceil(count / (K-1))
            for j in range(1, K - (count % K)):
                if i+j < N+1:
                    A[i+j] = a
            count = 0
    else:
        count += 1

print(answer)

Submission status: Wrong Answer

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

a = min(A)

count = 0
answer = 0
A.append(a)
for i in A:
    if i == a:
        answer += math.ceil(count / (K-1))
        count = 0
    else:
        count += 1

print(answer)

Submission status: Wrong Answer

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

a = min(A)

count = 0
answer = 0
A.append(a)
for i in A:
    if i == a:
        answer += math.ceil(count / 2)
        count = 0
    else:
        count += 1

print(answer)

Submission status: Wrong Answer

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

a = min(A)

count = 0
answer = 0
A.append(1)
for i in A:
    if i == 1:
        answer += math.ceil(count / 2)
        count = 0
    else:
        count += 1

print(answer)

Submission status: Wrong Answer

Solution code:
import math

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

position_one = num_lsit.index(1)
print (math.ceil(position_one / (k-1)) + math.ceil((n-position_one-1)/(k-1)) )

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
R = N - i - 1
out = (L-1)//(K-1) + 1 + (R-1)//(K-1) + 1
print(out)

Submission status: Wrong Answer

Solution code:
line = input().split()
N = line[0]
K = line[1]

A = list(map(int, input().split()))
i = A.index(min(A))
print(str(((i+1)//2) + ((len(A)-i)//2)) )

Submission status: Wrong Answer

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

A=int(N/(N-N%K))
print(A)

Submission status: Wrong Answer

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

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

print(N // (K - 1))

Submission status: Wrong Answer

Solution code:
import math


nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
a = input().split()
min_i = a.index("1")
ans = min(math.ceil(min_i / (k - 1)) + math.ceil((n - min_i - 1) / (k - 1)), math.ceil((min_i - 1) / (k - 1)) + math.ceil((n - min_i - 2) / (k - 1)) + 1)
print(ans)

Submission status: Wrong Answer

Solution code:
import math


nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
a = input().split()
min_i = a.index("1")
ans = math.ceil(min_i / (k - 1)) + math.ceil((n - min_i - 1) / (k - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
# 2019/04/09
# AtCoder Beginner Contest 103 - C

import math

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

# Linear Search
for i in range(n):
    if a[i] == 1:
        break

ans = math.ceil(i / (k-1))
ans += math.ceil(((n-1) - i) / (k-1))

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
list = [int(i) for i in input().split()] 
sort_list = sorted(list)
min_list = sort_list[0]

#print(sort_list[0])

flag = 0
for i in range(n):
    if list[i]==min_list:
        flag = i
i_after = n-flag
i_before = flag+1
count = 0

#print(flag)

#print(i_after,i_before)

if i_after % (k-1) == 1:
    None
elif i_after %(k-1)==0:
    None
else:
    count+=1
    
#print(count)

if i_before % (k-1) == 1:
    None
elif i_before % (k-1)==0:
    None
else:
    count += 1

#print(count)

count += i_after//(k-1)+i_before//(k-1)

print(count)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
list = [int(i) for i in input().split()] 
sort_list = sorted(list)
min_list = sort_list[0]

#print(sort_list[0])

flag = 0
for i in range(n):
    if list[i]==min_list:
        flag = i
i_after = n-flag
i_before = flag+1
count = 0

#print(flag)

#print(i_after,i_before)

if i_after % (k-1) == 1:
    None
elif i_after %(k-1)==0:
    None
else:
    count+=1
    
#print(count)

if i_before % (k-1) == 1:
    None
elif i_after % (k-1)==0:
    None
else:
    count += 1

#print(count)

count += i_after//(k-1)+i_before//(k-1)

print(count)

Submission status: Wrong Answer

Solution code:
# 2019/04/09
# AtCoder Beginner Contest 103 - C

import math

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

# Linear Search
for i in range(n):
    if a[i] == 1:
        break

ans = math.ceil(i / (k-1))
ans += math.ceil(((n-1) - i) / (k-1))
if i == 0 or i == n - 1:
    ans -= 1

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

left = A.index(1)
right = N - left - 1
K -= 1
print(min(math.ceil(right/K) + math.ceil(left/K),
          math.ceil((right-1)/K) + math.ceil((left-1)/K) + 1))

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline


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

a = [int(x) for x in input().rstrip().split()]

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter

input = sys.stdin.readline


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

a = [int(x) for x in input().rstrip().split()]

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter

input = sys.stdin.readline


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

a = [int(x) for x in input().rstrip().split()]

q = math.floor(n / k)+n % k
r = n % k
count = math.floor(n/k)

while(q > k):
    count += math.floor(q/k)
    q = math.floor(q / k) + q % k

if(n % k == 0):
    print(count)
else:
    print(count+1)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter

input = sys.stdin.readline


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

a = [int(x) for x in input().rstrip().split()]

q = math.floor(n / k)+n % k
r = n % k
count = math.floor(n/k)

while(q >= k):
    count += math.floor(q/k)
    q = math.floor(q / k) + q % k

if(n % k == 0):
    print(count)
else:
    print(count+1)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter

input = sys.stdin.readline


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

a = [int(x) for x in input().rstrip().split()]

q = math.floor(n / k)+n % k
r = n % k
count = math.floor(n/k)

while(q >= k):
    count += math.floor(q/k)
    q = math.floor(q / k) + q % k

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

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import Counter

input = sys.stdin.readline


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

a = [int(x) for x in input().rstrip().split()]

q = math.floor(n / k)+n % k
r = n % k
count = math.floor(n/k)

while(q >= k):
    count += math.floor(q/k)
    q = math.floor(q / k) + q % k
    print(count)

if(n == k):
    print(count)
else:
    print(count+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
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

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

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

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    a, b = map(int, input().split())

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

    ans = (a-1)//(b-1) + int((a-1) % (b-1))

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    a, b = map(int, input().split())

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

    c_sum = a - b

    ans = 1

    ans = ans + c_sum//(b-1) + int(c_sum % (b-1))

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    a, b = map(int, input().split())

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

    c_sum = a - b

    ans = 1

    ans = ans + int(c_sum/(b-1)) + int(c_sum % (b-1))

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    a, b = map(int, input().split())

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

    ans = int(a / b)

    if a % b != 0:
        ans = ans + a % b

    print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    a, b = map(int, input().split())

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

    ans = int(a / b)

    if a % b != 0:
        ans = ans + 1

    print(ans)

Submission status: Wrong Answer

Solution code:
import math
N,K = map(int,input().split())
L = list(map(int,input().split()))
k = 0
for i in range(N):
  if L[i] == 1:
    t = i
    break
ans = 0
if N != K:
  ans += 1+max(0,math.ceil((t+1-K)/(K-1)))
  ans += 1+max(0,math.ceil((N-t-K)/(K-1)))
  print(ans)
else:
  print(1)

Submission status: Wrong Answer

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

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

a_min = min(a)


def left(num):
    global a
    for i in range(3):
        if num - i - 1 >= 0:
            a[num-i-1] = a_min
    return

def right(num):
    global a
    for i in range(3):
        if num + i + 1 < n:
            a[num+i+1] = a_min
    return

cnt = 0

for i in range(n):
    if i >= 1:
        if a[i-1] != 1:
            cnt += 1
            left(i)
    if i < n - 1:
        if a[i+1] != 1:
            cnt += 1
            right(i)


print(cnt)

Submission status: Wrong Answer

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

min_ind = A.index(1)


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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int, input().split()))
#まずminのある位置をメモる
#そのあと空白の数を数える

min_index=[0]*N
min_A = min(A)

for i in range(N):
    if A[i]==min_A:
        min_index[i]=1
    
# print(min_index)

answer = 0
cnt = 0
chk1 = []
for i in range(N):
    if min_index[i]==0:
        cnt+=1
        chk1.append(0)
    else:
        if i==0:continue
        if cnt<K:
            cnt+=1
            chk1.append(1)
            continue
        if chk1.count(1)==cnt:
            chk1=[]
            continue

        chk1 = []
        if cnt%(K-1)==0:
            answer += cnt//(K-1)
        else:
            answer += cnt//(K-1)+1

        cnt = 0

if cnt%(K-1)==0:
    answer += cnt//(K-1)
if cnt%(K-1)!=0:
    answer += cnt//(K-1)+1


print(answer)

Submission status: Wrong Answer

Solution code:
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
print((N+K-2)//(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 = map(int,input().split())
A = list(map(int, input().split()))
#まずminのある位置をメモる
#そのあと空白の数を数える

min_index=[0]*N
min_A = min(A)

for i in range(N):
    if A[i]==min_A:
        min_index[i]=1
    
# print(min_index)

answer = 0
cnt = 0
for i in range(N):
    if min_index[i]==0:
        cnt+=1
    else:
        if i==0:continue
        if cnt<K:
            cnt+=1
            continue
        if cnt%(K-1)==0:
            answer += cnt//(K-1)
        else:
            answer += cnt//(K-1)+1

        cnt = 0

if cnt%(K-1)==0:
    answer += cnt//(K-1)
if cnt%(K-1)!=0:
    answer += cnt//(K-1)+1


print(answer)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int, input().split()))
#まずminのある位置をメモる
#そのあと空白の数を数える

min_index=[0]*N
min_A = min(A)

for i in range(N):
    if A[i]==min_A:
        min_index[i]=1
    
# print(min_index)

answer = 0
cnt = 0
for i in range(N):
    if min_index[i]==0:
        cnt+=1
    else:
        if i==0:continue
        if cnt%(K-1)==0:
            answer += cnt//(K-1)
        else:
            answer += cnt//(K-1)+1

        cnt = 0

if cnt%(K-1)==0:
    answer += cnt//(K-1)
if cnt%(K-1)!=0:
    answer += cnt//(K-1)+1


print(answer)

Submission status: Wrong Answer

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

def solve(N,K):
    if N == K:
        return 1
    K = K-1
    poj = 0
    one = A.index(1)
    right = N-one-1
    left = one
 
    if right < K and left < K:
        return 2
    if right < K:
        left = left - (K- right)
        right = 0
        poj = 1
    elif left < K:
        right = right - (K - left)
        left = 0
        poj = 1
    return (right+K-1)//K+(left+K-1)//K + poj
print(solve(N,K))

Submission status: Wrong Answer

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

def solve(N,K):
    if N == K:
        return 1
    K = K-1
    poj = 0
    one = A.index(1)
    right = N-one-1
    left = one
 
    if right < K and left > K:
        return 2
    if right < K:
        left = left - (K- right)
        right = 0
        poj = 1
    elif left < K:
        right = right - (K - left)
        left = 0
        poj = 1
    return (right+K-1)//K+(left+K-1)//K + poj
print(solve(N,K))

Submission status: Wrong Answer

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

n1 = A.index(1)
n2 = n - A.index(1) - 1

ans = int((n-1) / (k-1))
if n1%(k-1) != 0:
    ans += 1
if n2%(k-1) != 0:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, K = 0, 0
A = []


def set_inputs():
    global N, K, A
    N, K = get_li()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    if N == K:
        print(1)
        return
    k = K - 1
    print((N + k - 1) // k)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

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:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, K = 0, 0
A = []


def set_inputs():
    global N, K, A
    N, K = get_li()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    if N == K:
        print(1)
        return
    i = A.index(1)
    l, r = len(A[:i]), len(A[i+1:])
    k = K - 1
    print((l + k - 1) // k + (r + k - 1) // k)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
N, K = 0, 0
A = []


def set_inputs():
    global N, K, A
    N, K = get_li()
    A = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    if N == K:
        print(1)
    i = A.index(1)
    l, r = len(A[:i]), len(A[i+1:])
    k = K - 1
    print((l + k - 1) // k + (r + k - 1) // k)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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