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())
A = [int(i) for i in input().split()]

IDX = A.index(min(A))

ans = 0
ans += max(0, (IDX + K - 2) // (K - 1))
ans += max(0, (N - IDX + K - 3) // (K - 1))
print(ans)

Submission status: Wrong Answer

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

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

mid = A.index(1)
ans = -(-(mid + 1) // (K - 1)) + (-(-(N - mid) // (K - 1)))
print(min(ans, -(-N // (K - 1))))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
ans = (i+1)//2
ans += ((N-i-1-(i&1))+1)//2
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:
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))

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

p = 0
for k in range(N):
    if A[k] == 1:
        p = k+1
        break
print(ceil((p-1)/(K-1))+ceil((N-p)/(K-1)))

Submission status: Wrong Answer

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

mid = A.index(1)
ans = -(-(mid + 1) // (K - 1)) + (-(-(N - mid) // (K - 1)))
print(min(ans, -(-N // (K - 1))))

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()]
    mi = min(A)
    idx = A.index(mi)
    h1 = idx
    h2 = N - idx - 1
    print((h1 + (K-1) - 1)//(K-1) + (h2 + (K-1) - 1)//(K-1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
  n,k = input_list()
  a = input_list()
  if n <= k:
    print(1)
    exit(0)
  amari = n%k
  if amari > 1:
    print((n//k)+amari)
  else:
    print((n//k)+1)
  
def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return map(str, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

import math
import fractions
import collections
from functools import reduce
main()

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  if a[i]==1:
    x=i
    y=n-1-i
import math

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

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
  if a[i]==1:
    x=i
    y=n-1-i
def e(b,c):
  ans=0
  while b>0:
    ans+=1
    b-=c
  return ans 

if x%k==0 or y%k==0:
  print(e(n-1,k))
else:
  print(e(n,k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
li = list(map(int, input().split()))
i = li.index(1)
if i == 0 or i == n - 1:
    print(math.ceil((n-1)/(k-1)))
    exit()
l = i
r = n - i - 1
lc, lmod = divmod(l, k -1)
rc, rmod = divmod(r, k -1)

if lmod + rmod + 1 > k:
    print(lc + rc + 2)
else:
    print(lc + rc + 1)

Submission status: Wrong Answer

Solution code:
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
mim = min(A)
loc = []
for i in range(0,N):
    if A[i] == mim:
        loc.append(i)

#print(loc)

c = 0
for i in range(len(loc)):
    if i == 0:
        c += math.ceil( (loc[i]-0) / (K-1) )
    else:
        if loc[i]-loc[i-1] != 1:
            c += math.ceil( (loc[i]-loc[i-1]-1) / (K-1) )

c += math.ceil( ( (N-1)-loc[-1] ) / (K-1) )

print(c)

Submission status: Wrong Answer

Solution code:
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
mim = min(A)
loc = [0]
for i in range(1,N):
    if A[i] == mim:
        loc.append(i)

if N-1 not in loc:
    loc.append(N-1)
#print(loc)

c = 0
for i in range(len(loc)-1):
    if loc[i+1]-loc[i] != 1:
        c += math.ceil( (loc[i+1]-loc[i]) / (K-1) )

print(c)

Submission status: Wrong Answer

Solution code:
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))
mim = min(A)
loc = [0]
for i in range(1,N):
    if A[i] == mim:
        loc.append(i)

if N-1 not in loc:
    loc.append(N-1)
#print(loc)

c = 0
for i in range(len(loc)-1):
    c += math.ceil( (loc[i+1]-loc[i]) / (K-1) )

print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
start = Alist.index(1)
hand = K-1
l, r = start, N-start-1
ans = 0
if 0 < l <= hand:
    ans += 1
    r -= (hand-l)-1
    if r <= 0:
        print(ans)
        exit()
    if r <= hand:
        ans += 1
        print(ans)
        exit()
    else:
        ans += ceil(r/hand)
        print(ans)
        exit()

if 0 <  r <= hand:
    ans += 1
    l -= (hand-r)-1
    if l <= 0:
        print(ans)
        exit()
    if l <= hand:
        ans += 1
        print(ans)
        exit()
    else:
        ans += ceil(l/hand)
        print(ans)
        exit()
print(ceil(l/hand)+ceil(r/hand))

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
start = Alist.index(1)
hand = K-1
l, r = start, N-start-1
ans = 0
if l <= hand:
    ans += 1
    r -= (hand-l)
    if r <= 0:
        print(ans)
        exit()
    if r <= hand:
        ans += 1
        print(ans)
        exit()
    else:
        ans += ceil(r/hand)
        print(ans)
        exit()

if r <= hand:
    ans += 1
    l -= (hand-r)
    if l <= 0:
        print(ans)
        exit()
    if l <= hand:
        ans += 1
        print(ans)
        exit()
    else:
        ans += ceil(l/hand)
        print(ans)
        exit()
print(ceil(l/hand)+ceil(r/hand))

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
start = Alist.index(1)
hand = K-1
l, r = start, N-start-1
ans = 0
ans += ceil(l/hand)
r -= l%hand if l >= hand else 0
ans += ceil(r/hand)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import floor
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
start = Alist.index(1)
hand = K-1
l, r = start, N-start-1
ans = 0
print(floor(N/hand))

Submission status: Wrong Answer

Solution code:
from math import ceil
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
start = Alist.index(1)
hand = K-1
l, r = start, N-start-1
ans = 0
if l < hand:
    ans += 1
    r -= (hand-l)
    if r <= 0:
        print(ans)
        exit()
    if r < hand:
        ans += 1
        print(ans)
        exit()
    else:
        ans += ceil(r/hand)
        print(ans)
        exit()

if r < hand:
    ans += 1
    l -= (hand-r)
    if l <= 0:
        print(ans)
        exit()
    if l < hand:
        ans += 1
        print(ans)
        exit()
    else:
        ans += ceil(l/hand)
        print(ans)
        exit()
print(ceil(l/hand)+ceil(r/hand))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
pos = 0
for i in range(N):
  if A[i] == 1:
    pos = i
    break
ans = 0
if i <= K:
  ans += 1
  if N > K:
    ans += (N - K + K - 1)//(K - 1)
  print(ans)
  exit()

ans += (i - K + K - 1)//(K - 1)
ans += (N - i + 1 + K - 1)//(K - 1)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
n,k=map(int,input().split())
L=list(map(int,input().split()))
print(ceil(n/(k-1)) if n!=k else "1")

Submission status: Wrong Answer

Solution code:
import math
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
idx = a.index(1)
res = n
for j in range(max(0, idx-k), idx+1):
    if j != 0: b = math.ceil(j / (k-1))
    else: b = 0
    if j + k <= n - 1: a = math.ceil((n - (j+k-1)) / (k-1))
    else: a = 0
    res = min(res, 1 + a + b)
print(res)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

m = 1
i = A.index(m)
left = math.ceil((i - 1) / (K - 1))
right = math.ceil((N - i) / (K - 1))
if (i - 1) % (K - 1) == 0 or (N - i) % (K - 1) == 0:
    print(right + left)
else:
    print(right + left - 1)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = [-1] + list(map(int, input().split()))

m = 1
i = A.index(m)
left = math.ceil((i - 1) / (K - 1))
right = math.ceil((N - i) / (K - 1))

print(right + left)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
N,K=map(int,input().split())
A=''.join([i for i in input().split()])
B=A.split(min(A))
L=[len(b) for b in B]
ans=0
for l in L:
    ans += ceil(l/(K-1))
print(ans)

Submission status: Wrong Answer

Solution code:
def proc_array(s, e, li):
  for i in range(s, e):
    li[i] = 1
  return li

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
i = 0
while i < n:
  if a[i] == 1:
    break
  i += 1

if i == 0 or i == len(a)-1:
  s = 0
  while len(set(a)) != 1:
    ans += 1
    if s+k-1 >= len(a)-1:
      break
	
    a = proc_array(s, s+k, a)
    s = s + k - 1

else:
  # 左側と右側の処理
  s = i
  while len(set(a[0:i+1])) != 1:
    ans += 1
    if s-k+1 <= 0:
      break
	
    a = proc_array(s-k+1, s+1, a)
    s = s - k + 1
  
  s = i
  while len(set(a[i:])) != 1:
    ans += 1
    if s+k-1 >= len(a)-1:
      break
	
    a = proc_array(s, s+k, a)
    s = s + k - 1 

print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = list(map(int, input().split()))
x = A.index(1)+1
left = x//K + 1 if x % K != 0 else 0
right = (N-x+1)//K + 1 if (N-x+1) % K != 0 else 0
print(left+right)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil
n, k = map(int, input().split())
A = list(map(int, input().split()))
i1 = A.index(1)
print(ceil(n/(k-1)) if k<n else 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def cn(x, k):
    if x % (k-1) == 0:
        return x // (k-1)
    else:
        return x // (k-1) + 1


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

num = 0

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

print(cn(num, k) + cn(n-num-1, k))

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))
#print(min_index)
left = min_index 
right = N - left -1
#print("right",right,"left",left)
if left == 0 and right > 0:
	ans = math.ceil(right / (K - 1))
elif right == 0 and left > 0:
	ans = math.ceil(left / (K - 1))
elif right == 0 and left == 0:
	ans = 0
else:
	ans = math.ceil(left / (K - 1)) + math.ceil(right / (K - 1))
print(ans)

Submission status: Wrong Answer

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

num = 0

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

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split( ))
print((n+k-2)//(k-1))
#a要らない気がした

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = one
    right = N - one
    if right + 1 < K or left + 1 < K:
        print(ceil(N / K))
    else:
        print(ceil(left / (K - 1)) + ceil(right / (K - 1)))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = one + 1
    right = N - one + 1
    print(ceil(N / K))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = one + 1
    right = N - one + 1
    if right < K or left < K:
        print(ceil(N / K))
    else:
        print(ceil(left / K) + ceil(right / K))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = one + 1
    right = N - one + 1
    print(ceil(left / K) + ceil(right / K))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = one + 1
    right = N - one
    print(ceil(left / K) + ceil(right / K))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = one
    right = N - one - 1
    print(ceil(left / K) + ceil(right / K))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = N
    right = N - one - 1
    print(ceil(left / K) + ceil(right / K))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
Alist = list(map(int, input().split()))
if K >= N:
    print(1)
else:
    from math import ceil
    one = Alist.index(1)
    left = N
    right = N - one - 1
    print(ceil(left % K) + ceil(right % K))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    N, K = Scanner.map_int()
    A = Scanner.map_int()
    if N == K:
        print(1)
    else:
        print(Math.roundUp(N, (K - 1)))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

llength = len(A[:index+1])
lcounter = 0
while llength > 0:
  if llength == 1:
    break
  else:
    lcounter += 1
    llength -= (k-1)

rlength = len(A[index:])
rcounter = 0
while rlength > 0:
  if rlength == 1:
    break
  else:
    rcounter += 1
    rlength -= (k-1)

print(lcounter+rcounter)

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
a = na()

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

one = A.index(1)
print(ceil((one)/(K-1)) + ceil((N-one-1)/(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()

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

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N,M = map(int,input().split())
x=np.array(list(map(int,input().split())));x=np.sort(x)
print(1 if N==M else math.ceil(N/(M-1)))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M = map(int,input().split())
x=np.array(list(map(int,input().split())));x=np.sort(x)


print(1 if N==M else round(N/(M-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b= map(int, input().split())
c = list(map(int, input().split()))
num = c.index(1)
left = num
right = a - left - 1
left_2 = left % (b - 1)
right_2 = right % (b - 1)
for i in range(b+1):
    if (left - i) % (b - 1) == 0:
        amari = (right - (b-1-i)) % (b - 1)
        kaisu_left = (left - i) // (b - 1)
        kaisu_right = (right - (b-1-i)) // (b - 1)
print(kaisu_left + kaisu_right + 1 + amari)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K, *A = map(int, open(0).read().split())
I = A.index(1)
print(len(range(0, I, K-1))+len(range(I+1, N, K-1)))
# print(len(range(0, I, K-1)))
# print(len(range(I+1, N, K-1)))

Submission status: Wrong Answer

Solution code:
N, K, *A = map(int, open(0).read().split())
I = A.index(1)
print(len(range(0, I, K-1))+len(range(I, N, K-1)))

Submission status: Wrong Answer

Solution code:
N, K, *A = map(int, open(0).read().split())
I = A.index(1)
print((I+1)//(K-1)+(N-I)//(K-1))
# print((I+1)//(K-1))
# print((N-I)//(K-1))

Submission status: Wrong Answer

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

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

if N==K:
    print(1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

A.sort()

A_deque = deque(A)

count = 0
while len(A_deque) * A_deque[0] != sum(A_deque):
    count += 1
    if len(A_deque) >= 3:
        min_pop = min(A_deque.popleft(), A_deque.popleft(), A_deque.popleft())
        A_deque.appendleft(min_pop)
    else:
        min_pop = min(A_deque.popleft(), A_deque.popleft())
        A_deque.appendleft(min_pop)

print(count)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

A.sort()

A_deque = deque(A)

count = 0
while len(A_deque) > 3:
    count += 1
    min_pop = min(A_deque.popleft(), A_deque.popleft(), A_deque.popleft())
    A_deque.appendleft(min_pop)

print(count+1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

if n == k:
    ans = 1
else:
    m = int(n / (k - 1))
    s = k
    for i in range(1, m+2):
        s += (k - 1) 
        print(s)
        if s >= n:
            ans = i + 1
            break
        else:
            pass

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, k = map(int, input().split())
a_list = list(map(int, input().split()))

if n == k:
    ans = 1
else:
    ans = int(np.ceil(n / (k - 1)))

print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
i = input().split().index("1")
if k == n:
  print(1)
else:
  if i<k or i+k >= n:
    print(-(-(n-1)//(k-1)))
  else:
    print(-(-i//(k-1)) + -(-(n-i-1)//(k-1)))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
i = input().split().index("1")
if n == k:
  print(1)
else:
  print(-(-min(i, n-k)//(k-1)) -(-min(n-i-1, n-k)//(k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a = [i for i in input().split()]
one = a.index('1')
ans = 0
if n == k:
    ans = 1
elif one <= k//2:
    ans += 1
    for _ in range(one+k//2,n,k-1):
        ans += 1
elif n - k//2 - 1 <= one:
    ans += 1
    for _ in range(one-k//2,-1,-(k-1)):
        ans += 1
else:
    for _ in range(one,n,k-1):
        ans += 1
    for _ in range(one-1,-1,-(k-1)):
        ans += 1
print(ans)

Submission status: Wrong Answer

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


def contain(N, K, A, m, i):
    for j in range(i, min(i+K, N)):
        if A[j] == m:
            return True
    return False


def seek(N, A, m):
    for i in range(N):
        if A[i] != m:
            return i
    return N


def solve(N, K, A):
    m = min(A)
    i = seek(N, A, m)
    a = 0
    if i < N:
        a += 1
        i += (K-1)

    while i < N-1:
        if A[i+1] == m:
            i += 1
        else:
            a += 1
            i += K + contain(N, K, A, m, i+1) - 1
    return a


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    K = int(next(tokens))
    A = [int(next(tokens)) for _ in range(N)]
    print(solve(N, K, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def contain(N, K, A, m, i):
    for j in range(i, min(i+K, N)):
        if A[j] == m:
            return True
    return False


def seek(N, A, m):
    for i in range(N):
        if A[i] != m:
            return i
    return N


def solve(N, K, A):
    m = min(A)
    i = seek(N, A, m)
    a = 0
    if i < N:
        a += 1
        i += (K-1)

    while i < N-1:
        if A[i+1] == m:
            i += 1
        else:
            a += 1
            i += K + contain(N, K, A, m, i+1)
    return a


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    K = int(next(tokens))
    A = [int(next(tokens)) for _ in range(N)]
    print(solve(N, K, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def contain(N, K, A, m, i):
    for j in range(i, min(i+K, N)):
        if A[j] == m:
            return True
    return False


def seek(N, A, m):
    i = 0
    while i < N:
        if A[i] == m:
            i += 1
        else:
            return i

def solve(N, K, A):
    m = min(A)
    i = seek(N, A, m)
    a = 0
    if i < N:
        a += 1
        i += (K-1)

    while i < N-1:
        if A[i+1] == m:
            i += 1
        if contain(N, K, A, m, i+1):
            i += K
            a += 1
        else:
            i += (K-1)
            a += 1
    return a


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens)) 
    K = int(next(tokens)) 
    A = [int(next(tokens)) for _ in range(N)]
    print(solve(N, K, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def solve(N, K, A):
    m = min(A)
    i = 0
    a = 0
    while i < N:
        if A[i] == m:
            i += 1
        else:
            i += (K-1)
            a += 1
            if i < N:
                A[i] = m
    return a


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]"
    print(solve(N, K, A))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def solve(N, K, A):
    m = min(A)
    i = 0
    a = 0
    while i < N:
        if A[i] == m:
            i += 1
        else:
            i += (K-1)
            a += 1
    return a


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]"
    print(solve(N, K, A))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, K = map(int,input().split())
A = list(map(int,input().split()))

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

Submission status: Wrong Answer

Solution code:
N,K=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
A=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき


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

Submission status: Wrong Answer

Solution code:
import math

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

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

m=min(A)
a=A.index(m)
tmp=0
tmp+=math.ceil(a/(K-1))

if(N>(tmp*K)):
    M=tmp*K
else:
    M=N
tmp+=math.ceil((N-M)/(K-1))
print(tmp)

Submission status: Wrong Answer

Solution code:
import math

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

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

m=min(A)
a=A.index(m)
tmp=0
tmp+=math.ceil(a/(K-1))
tmp+=math.ceil((N-(tmp*K))/(K-1))
print(tmp)

Submission status: Wrong Answer

Solution code:
import math

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

if(K>=len(A)):
    print(1)
    exit()

m=min(A)
a=A.index(m)
tmp=0
tmp+=math.ceil(a/(K-1))
tmp+=math.ceil((N-a-1)/(K-1))
print(tmp)

Submission status: Wrong Answer

Solution code:
import math

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

m=min(A)
a=A.index(m)
tmp=0
tmp+=math.ceil(a/(K-1))
tmp+=math.ceil((N-a-1)/(K-1))
print(tmp)

Submission status: Wrong Answer

Solution code:
import math

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

m=min(A)
a=A.index(m)
tmp=0
tmp+=math.ceil(a/(K-1))
tmp+=math.ceil((N-a-1)/(K-1))