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

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

# 最終的に全て1になるので、最初の1の場所からなるべく効率的に1を広めればよい
index_1 = A.index(1)

# 中央から進める場合と、1に近い方の端から順に進める場合
if K <= index_1 <= (N-1) - (K-1) -1:
    # 初手、長さKの区間のどこに1がくるか
    tmp = []
    for i in range(K):
        len_rest_left = index_1 - i
        len_rest_right = N - len_rest_left - K
        tmp.append(math.ceil(len_rest_left/(K-1) + math.ceil(len_rest_right/(K-1))))
    ans = min(tmp)
else:
    ans = math.ceil((N-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()))

# 最終的に全て1になるので、最初の1の場所からなるべく効率的に1を広めればよい
index_1 = A.index(1)

# 中央から進める場合と、1に近い方の端から順に進める場合
if K <= index_1 <= (N-1) - K:
    # 初手、長さKの区間のどこに1がくるか
    tmp = []
    for i in range(K):
        len_rest_left = index_1 - i
        len_rest_right = N - len_rest_left - K
        tmp.append(math.ceil(len_rest_left/(K-1) + math.ceil(len_rest_right/(K-1))))
    ans = min(tmp)
else:
    ans = math.ceil((N-1)/(K-1))
    
print(ans)

Submission status: Wrong Answer

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

ind = A.index(1)
if ind == 0 or ind == N - 1:
    print(N // (K- 1))
else:
    print((ind + 1) // (K - 1) + (N - ind) // (K -1))

Submission status: Wrong Answer

Solution code:
import math

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

# 最終的に全て1になるので、最初の1の場所からなるべく効率的に1を広めればよい
index_1 = A.index(1)

# 左右別々に進める場合と、1に近い方の端から順に進める場合
if K-1 <= index_1 <= (N-1) - (K-1):
    n_right = math.ceil(((N-1)-index_1) / (K-1))
    n_left = math.ceil(index_1 / (K-1))
    ans = n_right + n_left
else:
    ans = math.ceil(N/K)
    
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

# 最終的に全て1になるので、最初の1の場所からなるべく効率的に1を広めればよい
index_1 = A.index(1)

n_right = math.ceil(((N-1)-index_1) / (K-1))
n_left = math.ceil(index_1 / (K-1))

print(n_right + n_left)

Submission status: Wrong Answer

Solution code:
n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
if k >= n:
    print(1)
    exit()
count = 0
while n > 0:
    n -= k
    n += 1
    count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

N, K = map(int, sys_input().split())
AAA = list(map(int, sys_input().split()))

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

n_remain = N
n_calc = 0
while n_remain > 0:
    n_remain += (-K+1)
    n_calc += 1

print(n_calc)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

one = A.index(1)
print((one + K - 2) // (K - 1) + (N - one - 1 + K - 2) // (K - 1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#101c
import math

N,K = map(int, input().split()) #K<=100
A_list = list(map(int, input().split()))

if len(A_list) <= K:
    print("1") #十分に短ければ1回で塗れる
elif len(A_list)%(K-1)==1:
    print(math.ceil(len(A_list)/(K-1))-1) #余りなく丁度塗れる場合
else:
    print(math.ceil(len(A_list)/(K-1)))

Submission status: Wrong Answer

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

a = max(math.ceil(A.index(1) / (K-1)), 1)
b = max(math.ceil((N - A.index(1)-1) / (K-1)), 1)

print (1 if K == N else a + b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = max((A.index(1) + 1) // (K-1), 1)
b = max((N - A.index(1)) // (K-1) ,1)

print (1 if K == N else a + b)

Submission status: Wrong Answer

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

a = max(A.index(1)-K, 1)
b = max(N-A.index(1)-K,1)

print (1 if K == N else a + b)

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)
else:
  print(math.floor(N / (K - 1) ))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
# Nの中からK個中最大でK-1個だけ変えることができるので
# N >= T*(K-1) + 1となり、この式をTを求めるように式変形する（Tは試行回数）
T = round((N - 1) / (K - 1))
print(T)

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
tmp = 0
for i in a:
    if i == 1:
        ans = math.ceil(tmp / (k - 1))
        tmp = n-tmp-1
        break
    tmp += 1
print(ans+math.ceil(tmp / (k - 1)))

Submission status: Wrong Answer

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

idx = a.index(1)
print(math.ceil((n-1)/(k-1)) if idx == 0 or idx ==
      n-1 else math.ceil(idx/(k-1)) + math.ceil((n-idx-1)/(k-1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

idx = a.index(1)
print(math.ceil(idx//(k-1)) + math.ceil((n-idx+1)//(k-1))
      if idx != 0 else 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()))

idx = a.index(1)
print(idx//(k-1) + (n-idx+1)//(k-1) if idx != 0 else (n-idx+1)//(k-1))

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
mn = min(a)
ans = 0
tmp = 0
for i in a:
    if mn == i:
        ans += math.ceil(tmp / (k-1))
        tmp = 0
        continue
    tmp += 1
print(ans + math.ceil(tmp / (k - 1)))

Submission status: Wrong Answer

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

minA = A.index(min(A))
ans = N

for i in range(K):
  count = 1
  left = minA - i
  right = minA + K - 1 - i
  #一回でK-1個を最小値にすることができる。
  if left >= 0:
    count += left // (K - 1)
    if left % (K - 1) != 0:
      count += 1
  if right != N -1:
    count += (N - right - 1) // (K - 1)
    if (N - right + 1) % (K - 1) != 0:
      count += 1
  if left >= 0:
    ans = min(count, ans)

print(ans)

Submission status: Wrong Answer

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

minA = A.index(min(A))
ans = N

for i in range(K):
  count = 1
  left = minA - i
  right = minA + K - 1 - i
  #一回でK-1個を最小値にすることができる。
  if left != 0:
    count += left // (K - 1)
    if left % (K - 1) != 0:
      count += 1
  if right != N -1:
    count += (N - right - 1) // (K - 1)
    if (N - right + 1) % (K - 1) != 0:
      count += 1
  ans = min(count, ans)
  
print(ans)

Submission status: Wrong Answer

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

minA = A.index(min(A))
ans = N

for i in range(K):
  count = 1
  left = minA - i
  right = minA + K - 1 - i
  #一回でK-1個を最小値にすることができる。
  if left != 0:
    count += (left // (K - 1)) + 1
  if right != N -1:
    count += ((N - right - 1) // (K - 1)) + 1
  ans = min(count, ans)
  
print(ans)

Submission status: Wrong Answer

Solution code:
#101c
import math

N,K = map(int, input().split()) #K<=100
A_list = list(map(int, input().split()))

#長さ N の数列 A1,A2,...,AN があります．最初，この数列の要素は 1,2,...,Nを並び替えたものになっています．
#この数列に対して次の操作を行うことができます．

#数列のうち，連続した K個の要素を選ぶ．その後，選んだ要素それぞれの値を，選んだ要素の中の最小値で置き換える．

#上の操作を何回か繰り返すことで，この数列の要素をすべて等しくしたいです．
#必要な操作の回数の最小値を求めてください． 
#この問題の制約の下，このようなことは必ず可能であることが証明できます．

#ex
#4 3
#2 3 1 4
#ans = 2
#1回目の操作では，1,2,3 番目の要素を選ぶ．すると，数列 A は 1,1,1,4になる．
#2回目の操作では，2,3,4 番目の要素を選ぶ．すると，数列 A は 1,1,1,1 になる

#8 3
#7 3 1 8 4 6 2 5
#ans=4

#結局すべての要素を最小の値(=1)に置き換える　を考えればOK
#1より左側を変更する回数と、1より右側を変更する合計の和　が回答となる
#もし1より左or右側の個数が一気に塗れる数より小さければ、余りで他の側を塗れるので、それを考慮する
if len(A_list) <= K:
    print("1") #十分に短ければ1回で塗れる
elif A_list.index(1)!=0 and (len(A_list)-1-A_list.index(1) <= K-2 or A_list.index(1) <= K-2): #左か右側を1回で塗れ、その時に反対側も一部塗れる。
    print(1 + math.ceil((len(A_list)-K)/(K-1)))
else:
    print(math.ceil(A_list.index(1)/(K-1)) + math.ceil((len(A_list)-1-A_list.index(1))/(K-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
one = a.index(1)
ans = 0
left = one
right = n - one

def count(n):
    global ans
    
    if n == 0:
        return 0
    elif n <= k:
        return 1
    elif n % k == 0:
        return (n//k) + 1
    else:
        return -(-n//k)

print(count(left) + count(right))

Submission status: Wrong Answer

Solution code:
import math

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

min_index = A.index(1)

l_cnt = min_index
r_cnt = N - 1 - min_index

cnt = 0
if l_cnt > 0:
    cnt += math.ceil(l_cnt / (K - 1))
    r_cnt -= l_cnt % (K - 1)
if r_cnt > 0:
    cnt += math.ceil(r_cnt / (K - 1))
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

min_index = A.index(1)

l_cnt = min_index
r_cnt = N - 1 - min_index

cnt = 0
if l_cnt > 0:
    cnt += math.ceil(l_cnt / (K - 1))
    if cnt == 1:
        r_cnt -= l_cnt % (K - 1)
if r_cnt > 0:
    cnt += math.ceil(r_cnt / (K - 1))
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

min_index = A.index(1)

l_cnt = min_index
r_cnt = N - 1 - min_index

cnt = 0
if l_cnt > 0:
    cnt += math.ceil(l_cnt / (K - 1))
if r_cnt > 0:
    cnt += math.ceil(r_cnt / (K - 1))
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

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

min_index = A.index(1)

l_cnt = min_index
r_cnt = N - 1 - min_index

cnt = math.ceil(l_cnt / (K-1)) + math.ceil(r_cnt / (K-1))

print(cnt)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
amin = 10**6
aind = -1
for i in range(N):
    if A[i]<amin:
        amin = A[i]
        aind = i
if (N-aind-1)%(K-1)==0:
    cr = (N-aind-1)//(K-1)
else:
    cr = (N-aind-1)//(K-1)+1
if aind%(K-1)==0:
    cl = aind//(K-1)
else:
    cl = aind//(K-1)+1
print(cr+cl)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
array = list(map(int, input().split()))
tmp = len(array)
ans = 0
while True:
    tmp -= K-1
    ans += 1
    if tmp < K-1:
        break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
ans=0
left=right=a.index(1)
while left>0:
    left=left-k+1
    ans+=1
while right<n-1:
    right=right+k-1
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, K = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    one_idx = A.index(1)
    one_left_num = one_idx
    one_right_num = N - (one_idx+1)
    from math import ceil
    print(ceil(one_left_num/(K-1)) + ceil(one_right_num/(K-1)) if N > K else 1)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

while N>0:
    N-=(K-1)
    flag+=1
print(flag)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
import numpy as np
print(int(np.ceil(idx/(k-1))+np.ceil((n-1-idx)/(k-1))))

Submission status: Wrong Answer

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

a = input()
print(math.ceil((n-1)//(c-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
min=l[0]
index=0
for i in range(n):
  if min>l[i]:
    min=l[i]
    index=i
index+=1
index2=n-index
sum=0
if index2%(m-1)==0:
  sum+=index2//(m-1)
else:
  sum+=index2//(m-1)+1
index3=index-1
if index3%(m-1)==0:
  sum+=index3//(m-1)
else:
  sum+=index3//(m-1)+1
print(sum)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l=list(map(int,input().split()))
min=l[0]
index=0
for i in range(n):
  if min>l[i]:
    min=l[i]
    index=i
index+=1
index2=n-index
sum=0
sum+=index2//m+1
index3=index-1
sum+=index3//m+1

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
i1 = A.index(1)
nl = len(A[:i1])
nr = len(A[i1+1:])
print(-(-nl//(K-1)) -(-nr//(K-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
ans2 = 1000000000000
count = a.index(1)
k = k - 1
p = (count-1) // k + 1
q = (n - count - 2) // k + 1
ans1 = p + q
if count <= k:
    ans2 = (n-1)//(k+1)+1
print(min([ans1, ans2]))

Submission status: Wrong Answer

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

count = a.index(1)
k = k - 1
p = (count-1) // k + 1
q = (n - count - 2) // k + 1
ans1 = p + q
ans2 = (n-1)//(k+1)+1
print(min([ans1, ans2]))

Submission status: Wrong Answer

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

count = a.index(1)
k = k - 1
if k == 0:
    print(n-1)
else:
    p = (count-1) // k + 1
    q = (n - count - 2) // k + 1
    print(p+q)

Submission status: Wrong Answer

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

count = a.index(1)
k = k - 1
p = (count-1) // k + 1
q = (n - count - 2) // k + 1
print(p+q)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

# 1〜Nの並び替えなので、最後は必ず1になる

# まず左端までを1に
count = 0
idx = A.index(1)

# 左の個数
left = idx
count += -(-left//(K-1))

# 右の個数
right = N-idx-1
count += -(-right//(K-1))

print(count)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

# 1〜Nの並び替えなので、最後は必ず1になる

# まず左端までを1に
count = 0
idx = A.index(1)

# 左の個数
left = idx
count += -(-left // (K-1))

# 右の個数
right = N-idx-1
count += -(-right // (K-1))

print(count)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

# 1〜Nの並び替えなので、最後は必ず1になる

# まず左端までを1に
count = 0
idx = A.index(1)

# 左の個数
left = idx
count += -(-left // 2)

# 右の個数
right = N-idx-1
count += -(-right // 2)

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print((n-1)//(k-1) if n > k else 1)

Submission status: Wrong Answer

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

print(n//(k-1) if n > k else 1)

Submission status: Wrong Answer

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

#print(-(-(N-1)//(K-1)))
print(N//(K-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()))
a = A.index(1)
b = -(-a//(k-1))*(k-1)+1
if n == k:
    print(1)
else:
    print(-(-a//(k-1))-(-(n-b-1)//(k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
A = list(map(int,input().split()))
a = A.index(1)
print((a+1)//(k-1)+(n-a)//(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()))

tmp = a.index(min(a))
amri = ((tmp) % (K - 1))
if amri == 0:
    ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
else:
    ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - amri) / (K - 1))
print(ans)

Submission status: Wrong Answer

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

tmp = a.index(min(a))
amri = ((tmp) % (K - 1))
if amri == 0:
    ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
else:
    ans = math.floor(tmp / (K - 1)) + math.ceil((N - tmp - 1 - amri) / (K - 1))
print(ans)

Submission status: Wrong Answer

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

tmp = a.index(min(a))

ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp) / (K - 1))
if N == K:
    ans = 1
    
print(ans)

Submission status: Wrong Answer

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

tmp = a.index(min(a))

ans = math.ceil(tmp / (K - 1)) + math.ceil((N - tmp - 1) / (K - 1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min_index = A.index(min(A))
# ans = min_index // (K - 1) + (N - min_index - 1) // (K - 1)
ans = (N - 1) // (K - 1) + (1 if N % K else 0)

print(ans)

Submission status: Wrong Answer

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

min_index = A.index(min(A))
# ans = min_index // (K - 1) + (N - min_index - 1) // (K - 1)
ans = N // (K - 1)

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n,k = map(int, input().split())
a = list(map(int, input().split()))
idx = a.index(1)
import numpy as np
print(int(np.ceil(idx/(k-1)) + np.ceil((n-idx-1)/(k-1))))

Submission status: Wrong Answer

Solution code:
def ceil(x, y):
    if x % y == 0:
        return x//y
    else:
        return (x//y)+1


def solve(n, k, ax):
    pivot = ax.index(1)
    if pivot == 0:
        right = 1
    else:
        right = 0
    left = ceil(pivot, k-1)
    if pivot < k:
        pivot = k-1
    right += ceil(n-pivot-1, k-1)
    return left+right


if __name__ == '__main__':
    n, k = map(int, input().split())
    ax = list(map(int, input().split()))
    print(solve(n, k, ax))

Submission status: Wrong Answer

Solution code:
def ceil(x, y):
    if x % y == 0:
        return x//y
    else:
        return (x//y)+1


def solve(n, k, ax):
    pivot = ax.index(1)
    if pivot == 0:
        right = 1
    else:
        right = 0
    left = ceil(pivot, k-1)
    if pivot < k:
        pivot = k-1
    right += ceil(n-pivot-1, k-1)
    print(n, k, pivot, left, right)
    return left+right


if __name__ == '__main__':
    n, k = map(int, input().split())
    ax = list(map(int, input().split()))
    print(solve(n, k, ax))

Submission status: Wrong Answer

Solution code:
def ceil(x, y):
    if x % y == 0:
        return x//y
    else:
        return (x//y)+1


def solve(n, k, ax):
    pivot = ax.index(1)
    left = ceil(pivot, (k-1))
    right = ceil((n-pivot-1), (k-1))
    return left+right


if __name__ == '__main__':
    n, k = map(int, input().split())
    ax = list(map(int, input().split()))
    print(solve(n, k, ax))

Submission status: Wrong Answer

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

print(len(a)//k+1 if len(a)%k!=0 else len(a)//k)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if n[0] <= n[1]:
    print('1')
else:
    print(math.ceil(n[0] / (n[1]-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
r=n-A.index(1)-1
l=A.index(1)
print(r//(k-1)+l//(k-1) if n>k else 1)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
r=len(A)-A.index(1)-1
l=A.index(1)
print(-(-r//(k-1))-(-l//(k-1)) if n>k else 1)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
A=list(map(int,input().split()))
r=len(A)-A.index(1)
l=A.index(1)
print(-(-r//(k-1))-(-l//(k-1)))

Submission status: Wrong Answer

Solution code:
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
def ceil(n,m):
  if n%m==0:
    return n//m
  else:
    return (n//m)+1
a=ls.index(1)
if K==N:
  print(1)
else:
  print(ceil(a,K-1)+ceil(N-a-1,K-1))

Submission status: Wrong Answer

Solution code:
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
def ceil(n,m):
  if n%m==0:
    return n//m
  else:
    return (n//m)+1
a=ls.index(1)  
print(ceil(a,K-1)+ceil(N-a-1,K-1))

Submission status: Wrong Answer

Solution code:
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
m=min(ls)
ans=0
before=-1
for i in range(N):
  if ls[i]==m:
    ans+=(i-before+K-3)//(K-1)
    before=i
ans+=(N-before+K-3)//(K-1)
print(ans)

Submission status: Wrong Answer

Solution code:


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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


minv_a = float('inf')
minv_i = -1
for i in range(N):
    if minv_a > A[i]:
        minv_a = A[i]
        minv_i = i

def get_first_obj(minv_a, idx):
    for i in range(idx+1, N):
        if minv_a < A[i]:
            return i

    return -1

def get_first_left(minv_a, idx):
    for i in range(idx-1, 0-1, -1):
        if minv_a < A[i]:
            return i

    return -1

count = 0
first = True
while True:
    if first:
        idx = get_first_obj(minv_a, minv_i)
        if idx != -1:
            count += 1
            for i in range(idx, min(idx+K-1, N)):
                A[i] = minv_a
        else:
            first = False

    if first == False:

        idx = get_first_left(minv_a, minv_i)
        if idx == -1:
            print(count)
            exit()
        else:
            count += 1
            for i in range(idx, max(0-1, idx-K), -1):
                A[i] = minv_a

Submission status: Wrong Answer

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

mn_i = a.index(1)

l = mn_i % (k - 1)
r = (n - mn_i - 1) % (k - 1)

tmp = (mn_i - 1) // (k - 1) + (n - mn_i - 2) // (k - 1) + 2

if l + r < k:
    print(tmp)
else:
    print(tmp + 1)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
As = list(map(int, input().split()))
#i = As.index(1)
#r = (i +(K-1)-1)//(K-1)+(N-i-1 +(K-1)-1)//(K-1)
r = (N +(K-1)-1)//(K-1)
print(r)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
As = list(map(int, input().split()))
i = As.index(1)
r = (i +(K-1)-1)//(K-1)+(N-i-1 +(K-1)-1)//(K-1)
print(r)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a
# C - Minimization
import math
N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

min_x = min(a_list)
min_x_i_list = [i for i, a in enumerate(a_list) if a == min_x]

c = 0

# 最初のi
start_x_i = min_x_i_list[0]
# 最初に左側を、できるだけ無駄がでないようにして埋める
if start_x_i + 1 < K:
    index = K - 1
    c += 1
else:
    x = math.ceil((start_x_i - 1) / (K - 1))
    index = (K - 1) * x
    c += x

while index < N - 1:  # 10 ** 5
    # index < j <= index + Kの範囲にmin_xがいるか
    next_min_list = [y for y in min_x_i_list if (index < y) and y <= (index + K)]
    if next_min_list:
        index += K
        c += 1
    else:
        index += K - 1
        c += 1

print(c)