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 = map(int, input().split())
List = list(map(int, input().split()))
TopList=List[:List.index(1)+1]
EndList=List[List.index(1):]

cnt=0
if len(EndList)!=1:
    i=0
    while i<len(EndList):
        if i==len(EndList)-1:
            cnt+=1
        elif i%(K-1)==0 and i!=0:
            cnt+=1
        EndList[i]=1
        #print(EndList)
        i+=1
        #print(cnt)
    
if len(TopList)!=1:
    #print("AA")
    TopList.reverse()
    j=0
    while j<len(TopList):
        if j==len(TopList)-1:
            cnt+=1
            #print("A")
        elif j%(K-1)==0 and j!=0:
            #print("B")
            cnt+=1
        TopList[j]=1
        #print(TopList)
        j+=1
        #print(cnt)

#print("AA")
print(cnt)

Submission status: Wrong Answer

Solution code:
import math

n, k = map(int, input().split())
a = list(map(int, input().split()))
l = a.index(1)
r = n - l - 1
if n == k:
    print(1)
else:
    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 = list(map(int, input().split()))
l = a.index(1)
r = n - l - 1
print(math.ceil(l / (k - 1)) + math.ceil(r / (k - 1)))

Submission status: Wrong Answer

Solution code:
import sys

N, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))

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

Submission status: Wrong Answer

Solution code:
import sys

N, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))

print(N // (K - 1))

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
# print(f"N:{N} K:{K} A:{A}", file=sys.stderr)

zero_index = 0
for i in range(len(A)):
    if A[i] == 1:
        zero_index = i
        break

count = 0
### 1の右側を全部1にする回数を求める
### 右側から数えて K個, K-1個, ... K-1個 でzero_index に届く回数を確かめる
zero_left_index = len(A)

zero_left_index -= K
count += 1
while zero_left_index > zero_index:
    zero_left_index -= (K - 1)
    count += 1

# print(f"zero_index:{zero_index} count:{count} zero_left_index:{zero_left_index}", file=sys.stderr)

### zero_left_index(全部1になっている列の一番左) を全部1にする回数を求める
if zero_index != 1 and zero_left_index > 0:
    # zero_left_index -= K
    # count += 1
    while zero_left_index > 0:
        zero_left_index -= (K - 1)
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
A = [0] + list(map(int, input().split()))
# print(f"N:{N} K:{K} A:{A}", file=sys.stderr)

zero_index = 0
for i in range(len(A)):
    if A[i] == 1:
        zero_index = i
        break

count = 0
### 1の右側を全部1にする回数を求める
### 右側から数えて K個, K-1個, ... K-1個 でzero_index に届く回数を確かめる
zero_left_index = len(A)

zero_left_index -= K
count += 1
while zero_left_index > zero_index:
    zero_left_index -= (K - 1)
    count += 1

# print(f"zero_index:{zero_index} count:{count} zero_left_index:{zero_left_index}", file=sys.stderr)

### zero_left_index(全部1になっている列の一番左) を全部1にする回数を求める
if zero_index != 1 and zero_left_index > 0:
    zero_left_index -= K
    count += 1
    while zero_left_index > 0:
        zero_left_index -= (K - 1)
        count += 1

Submission status: Wrong Answer

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

print(n // (m - 1) if n % m == (0 or 1) else n // (m - 1) + 1)

Submission status: Wrong Answer

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

print(n // (m - 1) if n % m == 0 or 1 else n // (m - 1) + 1)

Submission status: Wrong Answer

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

print(int(n/k) + int(n%k))

Submission status: Wrong Answer

Solution code:
N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
I = A.index(1)
R_Start = I - I%(K-1) + K #実質的なスタート
print((N+K-2)//(K-1))

Submission status: Wrong Answer

Solution code:
N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
I = A.index(1)
R_Start = I - I%(K-1) + K #実質的なスタート
print(N//(K-1))

Submission status: Wrong Answer

Solution code:
N,K = [int(hoge) for hoge in input().split()]
A = [int(hoge) for hoge in input().split()]
I = A.index(1)
R_Start = I - I%(K-1) + K #実質的なスタート
print(I//(K-1) + 1 + (N-R_Start+1)//(K-1))
#[AAA][AAA][AAA][AAA][BAAA]
#[AAA][AAA][AAA][AAA][ABAA]
#[AAA][AAA][AAA][AAA][AABA]
#[AAA][AAA][AAA][AAA][AAAB]

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, K = readnums()
    A = list(readnums())
    i = A.index(min(A))
    ans = i // (K - 1) if not i % (K - 1) else i // (K - 1) + 1
    ans += (N - i - 1) // (K - 1) if not (N - i - 1) % (K - 1) else(N - i - 1) // (K - 1) + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
input = sys.stdin.readline


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


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N, K = readnums()
    A = list(readnums())
    i = A.index(min(A))
    ans = i // 2 if not i % 2 else i // 2 + 1
    ans += (N - i - 1) // 2 if not (N - i - 1) % 2 else(N - i - 1) // 2 + 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Change = K - 1

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())
A = list(map(int,input().split()))

Change = K - 1

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())
A = list(map(int,input().split()))

Change = K - 1

print(N//(K-1))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = a.index(1)+1
right = n-pos
left = pos-1
ans = 0
if n == k:
    print(1)
    exit()
if right < k-1:
    right = 0
    left = n-k
    ans = 1
elif left < k-1:
    left = 0
    right = max(k,right)
    ans = 1
print(math.ceil(right/(k-1)) + math.ceil(left/(k-1))+ans)

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
pos = a.index(1)+1
right = n-pos
left = pos-1
ans = 0
if n == k:
    print(1)
    exit()
if right < k-1:
    right = 0
    left = n-k
    ans = 1
elif left < k-1:
    left = 0
    if right != k:
        right = k
    ans = 1
print(math.ceil(right/(k-1)) + math.ceil(left/(k-1))+ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil

N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==N:
    print(1)
    exit()
if N%(K-1)==1:
    print(N//(K-1))
else:
    print(ceil(N/(K-1)))

Submission status: Wrong Answer

Solution code:
from math import ceil

N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==N:
    print(1)
    exit()
if N%(K-1)==1:
    print(N//(K-1))
else:
    print(ceil(N//(K-1)))

Submission status: Wrong Answer

Solution code:
from math import ceil
import numpy as np
N,K=map(int, input().split())
A=list(map(int, input().split()))
if K==N:
    print(1)
    exit()
A=np.array(A)
idx=np.argmin(A)
print(ceil(N//(K-1)))

Submission status: Wrong Answer

Solution code:
import math

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

min_index = A.index(min(A))

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

Submission status: Wrong Answer

Solution code:
from math import ceil
import numpy as np
N,K=map(int, input().split())
A=list(map(int, input().split()))
A=np.array(A)
idx=np.argmin(A)
print(ceil(N//(K-1)))

Submission status: Wrong Answer

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

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))

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

Submission status: Wrong Answer

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

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

idx = a.index(1)

left = idx
right = n - (idx + 1)

ans = 10 ** 10

for i in range(k):
    cnt = 1
    left_ = left - i
    right_ = right - (k - 1 - i)
    cnt += left_//(k - 1) + right_//(k - 1) + int(left_ % (k - 1) == 1) + int(right_ % (k - 1))
    ans = min(ans, cnt)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

min_index = A.index(min(A))

ans = math.ceil((min_index)/(K-1))
ans += math.ceil((len(A)-min_index-1)/(K-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

idx = a.index(1)

left = idx
right = n - (idx + 1)

ans = left//(k - 1) + right//(k - 1) + int(left % (k - 1) == 1) + int(right % (k - 1))

print(ans)

Submission status: Wrong Answer

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

a = tuple(map(int,input().split()))

idx = a.index(1)

if idx==0:
  print((n-1)//(k-1))
else:
  ans = -(-(idx-2))//(k-1) + (n-idx+2)//(k-1)
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = tuple(map(int,input().split()))

idx = a.index(1)

if idx==0:
  print((n-1)//(k-1))
else:
  ans = -(-(idx+2)//k) + (n-idx)//k
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#最小の値を探し、そこから左右の数をカウントしたものをl_num,r_numとすると、
#ans = math.ceil((l_num-1)/2)+math.ceil((r_num-1)/2)

min_num = min(a_input)
min_index = a_input.index(min_num)

L_num = min_index
R_num = n-min_index-1

if min_index==0:
    ans = math.ceil((R_num-2)/2)+1    
elif min_index==n-1:
    ans = math.ceil((L_num-2)/2)+1
else:
    ans = math.ceil((L_num-1)/2)+math.ceil((R_num-1)/2)+1
print(ans)

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,M=pin()
    print((N-1)//(M-1))

#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,M=pin()
    print(N//(M-1))

#%%submit!
resolve()

Submission status: Wrong Answer

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())

n,k = map(int, stdin.readline().rstrip().split())
A = list(map(int, stdin.readline().rstrip().split()))

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
minA = min(a)
C = [1 if x==minA else 0 for x in a]
cnt=0
res=0
for i in range(n):
    if a[i] == 1:
        res += -(-cnt//(k-1))
        cnt = 0
    else:
        if i==n-1:
            cnt+=1
            res += -(-cnt//(k-1))
        else:
            cnt+=1
print(res)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = list(map(int,input().split()))
minI = a.index(min(a))+1
cnt1 = -(-(minI-1)//(k-1))
cnt2 = -(-(n-minI)//(k-1))
cnt = cnt1+cnt2
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if A.index(1) + N - A.index(1) - 1 < K:
    print(1)
else:
    mn = N
    for i in range(1, K-1):
        mn = min(mn, int(np.ceil(A.index(1)+i/(K-1))+np.ceil((N - A.index(1)-1+(K-i-1))/(K-1))))
    
    print(min(int(np.ceil(A.index(1)/(K-1))+np.ceil((N - A.index(1) - 1)/(K-1))), mn))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if A.index(1) + N - A.index(1) - 1 < K:
    print(1)
else:
    print(min(int(np.ceil(A.index(1)/(K-1))+np.ceil((N - A.index(1) - 1)/(K-1))),
              1+int(np.ceil(A.index(1)-1/(K-1))+np.ceil((N - A.index(1))/(K-1)))))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

if A.index(1) + N - A.index(1) - 1 < K:
    print(1)
else:
    print(int(np.ceil(A.index(1)/(K-1))+np.ceil((N - A.index(1) - 1)/(K-1))))

Submission status: Wrong Answer

Solution code:
import sys
import os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
i = ar.index(1)
x = i 
y = i
count = 0
while True:
    if x <= 0:
        break
    x -= b - 1
    count += 1
while True:
    if y >= a - 1:
        break
    y += b - 1
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
i = ar.index(1)
x = i 
y = i
count = 0
if i != 0:
    while True:
        if x <= 0:
            break
        x -= b - 1
        count += 1
if i != a-1:
    while True:
        if y >= a - 1:
            break
        y += b - 1
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
a,b = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
count = 1
a -= b
if a <= b and a != 0:
    count += 1
elif a // (b - 1) == 0:
    count += a // (b - 1)
else:
    count += a // (b - 1) + 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
import os

def file_input():
    f = open('ARC099/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    # int(input())
    N,K=map(int, input().split())
    A_li=list(map(int, input().split()))
    # print(min)

    print(N//(K-1))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
N, K =map(int, input().split())
li = list(map(int, input().split()))
a = li.index(min(li))
ans = math.ceil(a/(K-1)) + math.ceil((len(li)-a-1)/(K-1))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math


def main():
    n, k = input_list()
    a = input_list()
    print(n // (k-1))


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
n,k = [int(e) for e in input().split(" ")[:2]]
input()
print(math.ceil(n/(k-1)))

Submission status: Wrong Answer

Solution code:
n,k = [int(e) for e in input().split(" ")[:2]]
input()
print(n//(k-1))

Submission status: Wrong Answer

Solution code:
import numpy as np

n,k = [int(e) for e in input().split(" ")[:2]]
a_ls = np.array([int(e) for e in input().split(" ")[:n]])

if n <= 3:
	print(1)
else:
	idx_1 = np.argmin(a_ls)
	l_len = idx_1 + 1
	r_len = n - idx_1
	out_n = (l_len // (k-1)) + (r_len // (k-1))
	print(out_n)

Submission status: Wrong Answer

Solution code:

import math

def input_num():
	ls = input().strip().split(" ")
	return [int(e) for e in ls]

n,k = input_num()
a_ls = input_num()

min_a = min(a_ls)
min_idx = None
for i in range(n):
	if a_ls[i] == min_a:
		min_idx = i
		break

def calc_kai(m, k):
	return math.ceil((m-1)/(k-1))

print(calc_kai(min_idx+1,k) + calc_kai(n-min_idx,k))

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,k = iim()
A = iil()

num = A.index(1)
#if num <= k:
#    print(1+(n-2)//(k-1))
#else:
print((n+k-2)//(k-1))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math

n, k = map(int, input().split())
s = [int(i) for i in sys.stdin.read().split()]
s = np.array(s)
minindex = [i for i, x in enumerate(s) if x == min(s)]

if minindex[0] != 0:
    minindex.insert(0, 0)
if minindex[-1] != n-1:
    minindex.append(n-1)

ans = 0
tmp = 0
for i in minindex[1:]:
    ans += math.ceil((i - tmp)/(k-1))
    tmp = i

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

n, k = map(int, input().split())
s = [int(i) for i in sys.stdin.read().split()]
ss = np.array(s)
minindex = [i for i, x in enumerate(ss) if x == min(ss)]
ans = 0
tmp = 0
for i in minindex:
    ans += round((i - tmp)/k)
    tmp = i

if minindex[-1] != n-1:
    ans += round((n - tmp)/(k-1))
print(ans)

Submission status: Wrong Answer

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

ans = 0
if K == 1:
    print(N)
elif K == N:
    print(1)
else:
    for i in range(1, N + 1, 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 K == 1:
    print(N - 1)
elif N == K:
    print(1)
else:
    if (N - K) % (K - 1) != 0:
        print((N - K) // (K - 1) + 1)
    else:
        print((N - K) // (K - 1))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = n// (k-1)

print(ans)

Submission status: Wrong Answer

Solution code:

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


x = a.index(1)

ans = (x+1) // (k-1) + (n-x) // (k-1)

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/arc099/tasks/arc099_a
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]

MIN = min(nums)
index = nums.index(MIN)
ans = 0
if index % (k - 1) == 0:
    ans += index // (k - 1)
else:
    ans += index // (k - 1) + 1
if (len(nums) - 1 - index) % (k - 1) == 0:
    ans += (len(nums) - 1 - index) // (k - 1)
else:
    ans += (len(nums) - 1 - index) // (k - 1) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/arc099/tasks/arc099_a
n, k = map(int, input().split())
nums = [int(i) for i in input().split()]

MIN = min(nums)
index = nums.index(MIN)
ans = index // (k - 1) + (len(nums) - index) // (k - 1)
print(ans)

Submission status: Wrong Answer

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


def solve(N: int, K: int, A: "List[int]"):
    if N % (K - 1) in (0, 1):
        print(N // (K-1))
        return
    print(N // (K-1) + 1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, K = map(int,input().split())
A = list(map(int,input().split()))
p1 = A.index(1)
a = (p1)//2 + 1 + (N-p1-2)//2 
b = (p1)//2 + 1 + (N-p1-1)//2
c = (p1+1)//2 + 1 + (N-p1-1)//2
print(min(a,b,c))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   return ceil(N-1 + K -1)

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   if(N == K): return 1
   if(K == 2): return N - 1
   total = K *ceil(N/K) - (ceil(N/K) - 1)
   ans = ceil(N/K)
   # print(total,ans)
   if(total < N):
      ans += 1
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   if(N == K): return 1
   total = K *ceil(N/K) - ceil(N/K)
   ans = ceil(N/K)
   if(total < N):
      ans += 1
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   if(N == K): return 1
   total = K *ceil(N/K) - (ceil(N/K) - 1)
   ans = ceil(N/K)
   # print(total,ans)
   if(total <= N):
      ans += 1
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
from math import ceil
def myAnswer(N:int,K:int,A:list) -> int:
   if(N == K): return 1
   total = K *ceil(N/K) - (ceil(N/K) - 1)
   ans = ceil(N/K)
   # print(total,ans)
   if(total < N):
      ans += 1
   return ans

def modelAnswer():
   return
def main():
   N,K = map(int,input().split())
   A = list(map(int,input().split()))
   print(myAnswer(N,K,A[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)
if N==K:
    print(1)
    exit()

idx = arrA.index(1)
left = arrA[:idx]
right = arrA[idx+1:]

if arrA[0]==1 or arrA[-1]==1:
    if (N-1)%(K-1)==0:
        print((N-1)//(K-1))
        exit()
    else:
        print((N-1)//(K-1)+1)
        exit()

ans = 0
if len(left)+1<K:
    num = K-(len(left)+1)
    ans += 1
    left = []
    right = right[num:]
if len(right)+1<K:
    num = K-(len(right)+1)
    ans += 1
    right = []
    left = left[:-num] 

if len(left)%(K-1)==0:
    leftnum = len(left)//(K-1)
else:
    leftnum = len(left)//(K-1)+1
if len(right)%(K-1)==0:
    rightnum = len(right)//(K-1)
else:
    rightnum = len(right)//(K-1)+1
ans += leftnum + rightnum
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)
if N==K:
    print(1)
    exit()

idx = arrA.index(1)
left = arrA[:idx]
right = arrA[idx+1:]

ans = 0
if len(left)+1<K:
    num = K-(len(left)+1)
    ans += 1
    left = []
    right = right[num:]
if len(right)+1<K:
    num = K-(len(right)+1)
    ans += 1
    right = []
    left = left[:-num] 

if len(left)%(K-1)==0:
    leftnum = len(left)//(K-1)
else:
    leftnum = len(left)//(K-1)+1
if len(right)%(K-1)==0:
    rightnum = len(right)//(K-1)
else:
    rightnum = len(right)//(K-1)+1
ans += leftnum + rightnum
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
# arrA = np.array(input().split(),dtype=np.int64)
idx = arrA.index(1)
left = arrA[:idx]
right = arrA[idx+1:]
if len(left)%(K-1)==0:
    leftnum = len(left)//(K-1)
else:
    leftnum = len(left)//(K-1)+1
if len(right)%(K-1)==0:
    rightnum = len(right)//(K-1)
else:
    rightnum = len(right)//(K-1)+1
ans = leftnum + rightnum
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))