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: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 101 C Minimization
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    N, K = getIntList()
    d.dmp((N, K))
    A = getIntList()
    d.dmp(A)
    count = (N-1+K-2)//(K-1)
    return count


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Accepted

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

idx = 0
for i, a in enumerate(Ai):
    if a == 1:
        idx = i
        break
K2 = K - 1
left_num = idx
left_count = left_num // K2
if left_num % K2 > 0:
    left_count += 1

right_idx = K2 * (left_count - 1) + K

right_num = N - right_idx
right_count = right_num // K2
if right_num % K2 > 0:
    right_count += 1

print(left_count + right_count)

Submission status: Accepted

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

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

res = 1
cnt = k

if n <= cnt:
    print(res)
else:
    if (n-k)%(k-1) == 0:
        print(1 + (n-k)//(k-1))
    else:
        print(1 + (n-k)//(k-1)+1)

Submission status: Accepted

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

Submission status: Accepted

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

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

min_v = min(l)

min_idx = []

for i in range(n):
    if l[i] == min_v:
        min_idx.append(i)

tail = 0

curr_min = 0
pre_min_idx = 0
res = 0
idx = min_idx[0]
i = 0
while tail < n:
    for i in range(tail,n):
        if l[i]==min_v:
            idx = i
            break
    if idx != i:
        res += (n-tail)//(k-1) + (not not (n-tail)%(k-1)) 
        break
    interval = idx - tail
    num = interval//(k-1)
    delta = not not interval%(k-1)
    res += num+delta
    
    tail += (num+delta)*(k-1)+1
    #print(str(idx)+" "+str(tail)+" "+str(res)) 
print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import ceil


def solve(string):
    n, k, *a = map(int, string.split())
    return str(ceil((n - 1) / (k - 1)))


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))

Submission status: Accepted

Solution code:
import math

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


def main():
    print(math.ceil((N - 1) / (K - 1)))
    return


main()

Submission status: Accepted

Solution code:
input = open(0).read

N, K, *An = map(int, input().split())


def main():
    num = (N - 1) / (K - 1)
    print(int(num) + 1 if num != int(num) else int(num))
    return


main()

Submission status: Accepted

Solution code:
import math

input = open(0).read

N, K, *An = map(int, input().split())


def main():
    print(math.ceil((N - 1) / (K - 1)))
    return


main()

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    if k + (k-1) * i >= n:
        break
print(i+1)

Submission status: Accepted

Solution code:
from sys import stdin
import math
N, K = map(int, input().split())
a = [int(x) for x in stdin.readline().rstrip().split()]

N = N - K
cnt = 1

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

Submission status: Accepted

Solution code:
from math import ceil


def minimization(N: int, K: int, A: list) -> int:
    return 1 + ceil((N - K) / (K - 1))


if __name__ == "__main__":
    N, K = map(int, input().split())
    A = [int(s) for s in input().split()]
    ans = minimization(N, K, A)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

def f(m,n):
    ret=m/n
    ret_=int(ret)
    if ret_==ret:
        return ret_
    else:
        return ret_+1
      
N,K=list(map(int,input().split()))
a=np.array(list(map(int,input().split())))
print(f(np.sum(a!=min(a)),K-1))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
  if L[i]==1:
    base=i//(K-1)+(N-i-1)//(K-1)
    modulo=i%(K-1)+(N-i-1)%(K-1)

if modulo==0:
  print(base)
elif 1<= modulo < K:
  print(base+1)
else:
  print(base+2)

Submission status: Accepted

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys 
import math

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
import math

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

a.sort()
num = a.count(a[0])

answer = math.ceil((len(a) - num)/ (k-1))
print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(len(a)):
    if a[i]==1:
        p=i+1
        break
ans=0
ans+=p//(k-1)+1
right=n-(i+1)-(k-(i+1)%(k-1))
ans+=-(-right//(k-1))
print(ans)

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

Solution code:
n,k=map(int,input().split());print((n+k-3)//~-k)

Submission status: Accepted

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

if (N-K)%(K-1)==0:
    ans = (N-K)//(K-1) + 1
else:
    ans = (N-K)//(K-1) + 2

print(ans)

Submission status: Accepted

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

if n==k:
    print(1)
else:
    if (n-k)%(k-1)!=0:
        print(int((n-k)/(k-1))+2)
    else:
        print(int((n-k)/(k-1))+1)

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  ans = (N-1)//(K-1)
  if (N-1) % (K-1) != 0:
    ans += 1
  print(ans)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
N_K = [int(i) for i in input().split()] 
A = [int(i) for i in input().split()]

A = len(A)
a = 0
l_s = N_K[1]
l = 0
for i in range(N_K[0]):
    
    if l>=N_K[0]:
        print(a)
        
        break
    a = a+1
    l = l + l_s
    if l > l_s:
        l -= 1

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc101/tasks/arc099_a
import math


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    # print("{}, {}, {}".format(N-1, K-1, (N-1)/(K-1)))
    print(math.ceil((N-1)/(K-1)))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

for i in range(1,10**5+1):
    if i >= (N-K)/(K-1) + 1:
        print(i)
        exit()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N_K = list(map(int,input().split()))
A =  list(map(int,input().split()))
N = N_K[0]
K = N_K[1]

i = 0

while N > 0:
    if i == 0:
        N -= K
    else:
        N -= K - 1
    i +=1

print(i)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C
n,k=map(int,input().split())
print((n+k-3)//(k-1))

Submission status: Accepted

Solution code:
import numpy
n,r=map(int,input().split())
l=list(map(int,input().split()))
ans=numpy.ceil((n-1)/(r-1))
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from math import ceil


class Solver(object):
    def __init__(self):
        self.n, self.k = list(map(int, input().split(" ")))
        self.a_s = list(map(int, input().split(" ")))

    def solve(self):
        print(ceil((self.n-self.k) / (self.k-1)) + 1)


if __name__ == "__main__":
    s = Solver()
    s.solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

if n == k:
    print(1)
    exit()
    
n -= k
if n % (k-1) == 0:
    n //= k-1
else:
    n //= k-1
    n += 1
print(n+1)

Submission status: Accepted

Solution code:
N, K = input().split()
N = int(N)
K = int(K)
Alist = [int(x) for x in input().split()]

noMinLen = len(Alist) - Alist.count(min(Alist))
result = noMinLen / (K-1)

if result > noMinLen // (K-1):
    result = (noMinLen // (K-1)) + 1

print(int(result))

Submission status: Accepted

Solution code:
N ,K = map(int,input().split())
L = list(map(int,input().split()))
def ceil(x):
    if x == int(x):
        return x
    else:
        return int(x) + 1


cnt = 0

N = N - K 
cnt += 1
if N > 0:
    cnt += ceil(N / (K-1))
print(int(cnt))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


def solve(N, K, As):
    ans = 1
    N = N - K
    return ans + math.ceil(N / (K - 1))


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N,K = map(int, lines.pop(0).split(' '))
    A = list(map(int, lines.pop(0).split(' ')))
    min_a = min(A)
    idx = 0
    re = 0
    while( idx < N - 1):
        if ( all([i == min_a for i in A[idx:idx+K] ]) ):
            idx += K - 1
            continue
        else:
            re += 1
            idx += K - 1
    print(re)



#
# main
#

# 1. use list instead of stdin

#contents = '''\
#3 3
#1 2 3\
#'''
#lines = contents.split('\n')
# 
# 2. use stdin

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 101
# C - Minimization

N, K = [int(i) for i in input().split()]
# A = input().split()
print(-(-(N-1) // (K-1)))

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 101
# C - Minimization

N, K = [int(i) for i in input().split()]
A = input().split()
print(-(-(N-1) // (K-1)))

Submission status: Accepted

Solution code:
[print(int((n[0] - 2) / (n[1] - 1) + 1)) for n in [list(map(int, input().split()))]]

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    minA = min(A)
    if (N - A.count(minA)) % (K - 1) == 0:
        print((N - A.count(minA)) // (K - 1))
    else:
        print((N - A.count(minA)) // (K - 1) + 1)


main()

Submission status: Accepted

Solution code:
import math

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

min_idx = A.index(min(A))

count = N
start = max(0,min_idx-K+1)
end = min(start+K, N)
for i in range(start, end):
    tmp = math.ceil(i/(K-1)) + max(0, math.ceil((N-(i+K))/(K-1)))
    if count > tmp+1:
        count = tmp+1

print(count)

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n, k - 1):
    ans += 1
print(ans)

Submission status: Accepted

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


def main():
    from math import ceil

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

    print(1 + int(ceil((n - k) / (k - 1))))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
i = A.index(1)
l, r = i, N-i-1
div = [[j, K-1-j] for j in range(K)]
minval = 10000000
for d in div:
    if l-d[0] >= 0 and r-d[1] >= 0:
        minval = min(minval, ceil((l-d[0])/(K-1)) + ceil((r-d[1])/(K-1)) + 1)
print(minval)

Submission status: Accepted

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

count = 1
n -= k
count += n // (k - 1)
if n % (k - 1) != 0:
    count += 1
    
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n, k = map(int,input().split())
#an = list( map(int, input().split() ) )
n-=k
k-=1
print( 1+ n//k + (0 if n%k==0 else 1 ) )

Submission status: Accepted

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

def main():
    na = list(map(int, input().split()))
    N, K = na[0], na[1]
    A = list(map(int, input().split()))

    i1 = A.index(1)
    r = math.ceil((N - 1) / (K - 1))

    print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if N <= K:
    print(ans)
else:
    while num < N:
        num += K-1
        ans += 1
    print(ans)

Submission status: Accepted

Solution code:
count=0
n,k=map(int,input().split(" "))

while n>1:
  n=n-k
  n=n+1
  count=count+1
  
print(str(count))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(map(int,input().split()))
N = S[0]
K = S[1]
A = list(map(int,input().split()))
ans = (N-1)//(K-1)

if not (N-1) % (K-1) == 0:
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n -= k
count = 1
while n > 0:
    n -= k - 1
    count += 1
    
print(count)

Submission status: Accepted

Solution code:
N,K = [int(s) for s in input().split()]
data = [int(s) for s in input().split()]
i = 1
while True:
    if (K-1)*i + 1 >= N:
        print(i)
        exit()
    else:
        i += 1

Submission status: Accepted

Solution code:
N,K = map(int,input().split())
series = list(map(int,input().split()))
onepoint=series.index(1)
start = max(0,onepoint-K+1)
end = min(len(series),onepoint+K)
#print("start=",start,"end=",end)
ans = 10**9
for p in range(start,end):
	tmp = 0
	back = p
	front = p + K
	#print("back=",-(-back // (K-1)))
	#print("front=",-(-(len(series)-front) // (K-1)))
	tmp += -(-back // (K-1)) #Round Up
	tmp += -(-(len(series)-front) // (K-1))
	#print("tmp=",tmp)
	if ans > tmp:
		ans = tmp

print(ans+1)

Submission status: Accepted

Solution code:
from math import *
N, K = [int(x) for x in input().strip().split()]
print(ceil((N-1)/(K-1)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
from math import *
N, K = [int(x) for x in input().strip().split()]
A = [int(x) for x in input().strip().split()]
A.sort()
c = Counter(A)
minc = c[A[0]]
res = len(A) - minc
print(ceil(res/(K-1)))

Submission status: Accepted

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

length = len(AList ) - 1
ans = 0
while(length > 0):
    ans += 1
    length = length - (K - 1)
print(ans)

Submission status: Accepted

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

N = int(N)
K = int(K)

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

count = 1

if N > K:
    set = (N-K)//(K-1)
    count += set
    if (N-K)%(K-1) == 0:
        count += 0
    else:
        count += 1
print(count)

Submission status: Accepted

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

ans = 1
ans += (n - k) // (k - 1)
if (n - k) % (k - 1) != 0:
    ans += 1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, k = map(int, input().split())
A_list = list(map(int, input().split()))
def ceiling(n,div):
    return n // div + int(n % div != 0)
count = ceiling(n-1,k-1)
print(count)

Submission status: Accepted

Solution code:
import math

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

print(int(math.ceil(n+k-3)/(k-1)))

Submission status: Accepted

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

n -= k
count = 1

while n > 0:
    n -= (k - 1)
    count += 1
    
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in A:
    if i == 1:
        count += 1
        
if (n - k * count) % (k - 1)  != 0:
    ans =count +  (n - k * count) // (k - 1) + 1
else:
    ans = count + (n - k * count) // (k - 1) 

print(ans)

Submission status: Accepted

Solution code:
def main():
    n, k = map(int, input().split())
    aa = list(map(int, input().split()))
    m = aa.index(1) + 1
    i = 0
    c = 0
    while i < m:
        if i == 0:
            i += k
        else:
            i += (k - 1)
        c += 1
    r = max(n - i, 0)
    c += r // (k - 1) + int(r % (k - 1) != 0)
    print(c)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# print(-(-(n-1)//(k-1)))
print((n - 1 + (k - 2)) // (k-1))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
res = 1
if (N - 1) % (K - 1) == 0:
    print (N - 1) / (K - 1)
else:
    print (N - 1) / (K - 1) + 1

Submission status: Accepted

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

i=1
if n % k ==0:
  print(n//(k-1))
  exit()
else:
  while k+(k-1)*i< n:
    i+=1
print(1+i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
def main():
    line_input = input().split()
    n = int(line_input[0])
    k = int(line_input[1])
    nums = input().split()
    print(math.ceil((n - 1) / (k - 1)))

main()

Submission status: Accepted

Solution code:
def c_minimization(N, K, A):
    return ((N - 1) + (K - 1) - 1) // (K - 1)  # (N-1)/(K-1)を切り上げ

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(c_minimization(N, K, A))

Submission status: Accepted

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

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

Submission status: Accepted

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

minv = min(A)
minis = []
for i, a in enumerate(A):
    if a == minv:
        minis.append(i)

ans = 1e100
for mini in minis:
    l = mini // K + 1
    rd = K * l - l
    r = (N - 1 - rd - 1) // (K - 1) + 1
    ans = min(ans, l + r)
print(ans)

Submission status: Accepted

Solution code:
N, K = input().split()
N = int(N)
K = int(K)
A_list = [int(i) for i in input().split()]
step = K-1

for ans in range(N):
    if N <= K:
        print(ans+1)
        break
    K += step
    #print(ans)
    #print(N, K)

Submission status: Accepted

Solution code:
import math
N,K = map(int,input().split(" "))
array = list(map(int,input().split(" ")))
m = array.index(1)
i = m%(K-1) 
left = int((m-i)/(K-1))
right = math.ceil((N-m-(K-i))/(K-1))
print(left+right+1)

Submission status: Accepted

Solution code:
import sys
fin = sys.stdin.readline
from math import ceil

N, K = [int(elem) for elem in fin().split()]
A_list = [int(elem) for elem in fin().split()]

pos_1 = A_list.index(1)
# num_left = pos_1
# num_right = N - pos_1 - 1

min_operations = float('inf')
for offset in range(K):
    left_edge = pos_1 - offset
    right_edge = pos_1 + K - 1 - offset
    if left_edge >= 0 and right_edge >= 0:
        min_operations = min(min_operations, \
            ceil(left_edge / (K - 1)) + ceil((N - right_edge - 1) / (K - 1)) + 1)

print(min_operations)

Submission status: Accepted

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

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

Submission status: Accepted

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

if n == k:
    print(1)
    exit()

a = (n-k)//(k-1)
if (n-k)%(k-1):
    print(a+2)
else:
    print(a+1)

Submission status: Accepted

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

if (n-1)%(k-1) == 0:
	ans = (n-1)/(k-1)
else:
	ans = (n-1)//(k-1) + 1

print(int(ans))

Submission status: Accepted

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

minNum = min(A)

removedLen = len( [a for a in A if a != minNum ] )

import math

ans = math.ceil( removedLen/(K-1)) 

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    if a[i] == 1:
        min_idx = i
        break
ans = 10**9
for i in range(k):
    ans_cur = 1
    l = min_idx - i
    r = l + (k-1)
    if l > 0:
        ans_cur += l//(k-1)+1 if l%(k-1) > 0 else l//(k-1)
    if r < n-1:
        ans_cur += (n-1-r)//(k-1)+1 if (n-1-r)%(k-1) > 0 else (n-1-r)//(k-1)
    ans = min(ans, ans_cur)
print(ans)

Submission status: Accepted

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