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

a_min = min(A)

pos = 0
ans = 0
while pos < N:
    if A[pos] != a_min:
        pos += K - 1
        ans += 1
    else:
        pos += 1

print(ans)

Submission status: Wrong Answer

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

a_min = min(A)

c = 0
ans = 0
for idx, a in enumerate(A):
    if a == a_min:
        if c > 0:
            ans += (c+K-2)//(K-1)
            c = 0
    else:
        c += 1

if c > 0:
    ans += (c+K-2)//(K-1)

print(ans)

Submission status: Wrong Answer

Solution code:


def solve():
    N, K = map(int, input().split())
    Ax = list(map(int, input().split()))
    if N == K:
        print(1)
        exit()

    N -= K
    ans = 1

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

    print(ans)


# Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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


fi = 0
for i in range(n):
    if a[i] == 1:
        fi = i
        break

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

Submission status: Wrong Answer

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

index = A.index(1)

right_num = n - 1 - index
left_num = index

ans = math.ceil(right_num / (k-1))
ans += math.ceil(left_num / (k-1))

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
index=a.index(1)
l=index
r=index
cnt=0
if index<=(N//2-1 if N%2==0 else N//2):
  while l!=0:
    if cnt==0:
      if l-K+1<0:
        r=K-1
    l=max(0,l-K+1)
    cnt+=1
  while r!=N-1:
    r=min(N-1,r+K-1)
    cnt+=1
  print(cnt)
else:
  while r!=N-1:
    if cnt==0:
      if r+K-1>N-1:
        l=N-K
    r=min(N-1,r+K-1)
    cnt+=1
  while l!=0:
    l=max(0,l-K+1)
    cnt+=1
  print(cnt)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
index=a.index(1)
l=index
r=index
cnt=0
if index<=(N//2-1):
  while l!=0:
    if cnt==0:
      if l-K+1<0:
        r=K-1
    l=max(0,l-K+1)
    cnt+=1
  while r!=N-1:
    r=min(N-1,r+K-1)
    cnt+=1
  print(cnt)
else:
  while r!=N-1:
    if cnt==0:
      if r+K-1>N-1:
        l=N-K
    r=min(N-1,r+K-1)
    cnt+=1
  while l!=0:
    l=max(0,l-K+1)
    cnt+=1
  print(cnt)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
index=a.index(1)
l=index
r=index
cnt=0
while l!=0:
  if cnt==0:
    if l-K+1<0:
      r=K-1
  l=max(0,l-K+1)
  cnt+=1
while r!=N-1:
  r=min(N-1,r+K-1)
  cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
a=list(map(int,input().split()))
index=a.index(1)
l=index
r=index
cnt=0
while l!=0:
  l=max(0,l-K+1)
  cnt+=1
while r!=N-1:
  r=min(N-1,r+K-1)
  cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
k-=1
a=list(map(int, input().split()))
for i in range(n):
    if a[i]==1:
        index=i
print(-(-index//k)-(-(n-index-1)//k))#pythonで切り上げの書き方

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:
        index=i
print((i-1)//2+(n-i)//2+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def LI():
	return [ int(s) for s in input().split() ]
  
N,K = LI()
A = LI()
 
for idx,a in enumerate(A):
    if a == 1:
      min_index = idx
      break
      
if N - idx+1 > K and idx+1 > K:
  cnt = 0
  if (N-idx+1)%K == 0:
    cnt += (N-idx+1)//K
  else:
    cnt += (N-idx+1)//K + 1
  if (idx+1)%K == 0:
    cnt += (idx+1)//K
  else:
    cnt += (idx+1)//K + 1
  print(cnt)
else:
  print(N//K + 1) if N%K != 0 else print(N//K)

Submission status: Wrong Answer

Solution code:
def LI():
	return [ int(s) for s in input().split() ]
  
N,K = LI()
A = LI()

for idx,a in enumerate(A):
    if a == 1:
      min_index = idx
      break
      
if N - idx+1 > K and idx+1 > K:
  cnt = 0
  if (N-idx+1)%K == 0:
    cnt += (N-idx+1)//K
  else:
    cnt += (N-idx+1)//K + 1
  if (idx+1)%K == 0:
    cnt += (idx+1)//K
  else:
    cnt += (idx+1)//K + 1
else:
  print(N//K + 1) if N%K != 0 else print(N//K)

Submission status: Wrong Answer

Solution code:
def LI():
	return [ int(s) for s in input().split() ]
  
N,K = LI()

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

Submission status: Wrong Answer

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

ans = n//k
mod = (n-k)//(k-1) + min((n-k)%(k-1), 1)
print(ans + mod)

Submission status: Wrong Answer

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

idx = A.index(1)
L = idx // (K - 1) + (idx % (K - 1) != 0)
R = (N - 1 - idx) // (K - 1) + ((N - 1 - idx) % (K - 1) != 0)
print(L + R)

Submission status: Wrong Answer

Solution code:
import math

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

if((N+1)/K==2):
    print(2)
elif(N!=K):
    print(math.ceil(N/(K-1)))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

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

if((N+1)/K==2):
    print(math.ceil(N/(K-1)))
elif(N!=K):
    print(2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

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

if(N!=K):
    print(math.ceil(N/(K-1)))
elif((N+1)/K==2):
    print(2)
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

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

if(N!=K):
    print(math.ceil(N/(K-1)))
else:
    print(1)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
mi_index = A.index(min(A))
left_count = math.ceil(mi_index / (K - 1))
right_count = math.ceil((N - (mi_index + 1)) / (K - 1))

print(left_count + right_count)

Submission status: Wrong Answer

Solution code:
listlen, rensuu = map(int, input().split())
listnum = list(map(int, input().split()))
count = 0
count += (listlen - 1) // (rensuu - 1)
count += 1 if (listlen - 1) % (rensuu - 1) > 0 else 0
oneposi = listnum.index(1)
if rensuu < oneposi  + 1 < listlen - rensuu:
    count = len(listnum[:oneposi]) // (rensuu - 1) + len(listnum[oneposi + 1:]) // (rensuu - 1)
print(count)

Submission status: Wrong Answer

Solution code:
n, k = map(int,input().split())
a = list(map(int,input().split()))
g=1
while k+(k-1)*(g-1)<= n:
  g+=1
print(g)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
r=0
mn=min(l)
while len(l)>=1:
  if mn in l:
    m=l.index(mn)
    if m==0:
      l=l[1:]
    elif not mn in l[:k]:
      r+=1
      l=l[k:]
    else:
      c+=(r*k+m)//(k-1)
      if (r*k+m)%(k-1)!=0:
        c+=1
      l=l[m:]
      r=0
  else:
    c+=(r*k+len(l))//(k-1)
    if (r*k+len(l))%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
r=0
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(mn)
    if m==0:
      l=l[1:]
    if not mn in l[:k]:
      r+=1
      l=l[k:]
    else:
      c+=(r*k+m)//(k-1)
      if (r*k+m)%(k-1)!=0:
        c+=1
      l=l[m:]
      r=0
  else:
    c+=(r*k+len(l))//(k-1)
    if (r*k+len(l))%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
li=[int(i) for i in input().split()]
c=0
r=0
l=sorted(set(li), key=li.index)
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(mn)
    if m==0:
      l=l[1:]
    elif l[:k].count(mn)==0:
      r+=1
      l=l[k:]
    else:
      c+=(r*k+m)//(k-1)
      if (r*k+m)%(k-1)!=0:
        c+=1
      l=l[m:]
  else:
    c+=len(l)//(k-1)
    if len(l)%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
r=0
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(mn)
    if m==0:
      l=l[1:]
    elif l[:k].count(mn)==0:
      r+=1
      l=l[k:]
    else:
      c+=(r*k+m)//(k-1)
      if (r*k+m)%(k-1)!=0:
        c+=1
      l=l[m:]
  else:
    c+=len(l)//(k-1)
    if len(l)%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(min(l))
    if m!=0:
      if l[:k].count(mn)==1:
        c+=m//(k-1)
        if m%(k-1)!=0:
          c+=1
        l=l[m+1:]
      else:
        c+=1
        l=l[k:]
    else:
      l=l[m+1:]
  else:
    c+=len(l)//(k-1)
    if len(l)%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(min(l))
    if m!=0:
      if l[:k].count(mn)==1:
        c+=m//(k-1)
        if m%(k-1)!=0:
          c+=1
        l=l[m+1:]
      else:
        c+=1
        l=l[k:]
    else:
      l=l[m+1:]
  else:
    print("start",l)
    print(m,len(l)//(k-1),len(l)%(k-1))
    c+=len(l)//(k-1)
    if len(l)%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(min(l))
    if m!=0:
      if l[:k].count(mn)==1:
        c+=m//(k-1)
        if m%(k-1)!=0:
          c+=1
        l=l[m+1:]
      else:
        c+=1
        l=l[k+1:]
    else:
      l=l[m+1:]
  else:
    c+=len(l)//(k-1)
    if len(l)%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
c=0
mn=min(l)
while len(l)>=1:
  if mn==min(l):
    m=l.index(min(l))
    if m!=0:
      c+=m//(k-1)
      if m%(k-1)!=0:
        c+=1
    l=l[m+1:]
  else:
    c+=len(l)//(k-1)
    if len(l)%(k-1)!=0:
      c+=1
    l=[]
print(c)

Submission status: Wrong Answer

Solution code:
from math import ceil
n,k=map(int,input().split())
a=list(map(int,input().split()))
idx=-1
b=10**18
for i in range(n):
  if b>a[i]:
    idx=i
    b=a[i]
print(ceil(idx/(k-1))+ceil((n-idx-1)/(k-1)))

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = [int(x) for x in input().split()]
i1 = A.index(1)
ans = 0
tmp = i1
while True:
    if tmp <= 0:
        break
    tmp -= k - 1
    ans += 1
tmp = i1
while True:
    if n - 1 <= tmp:
        break
    tmp += k - 1
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = [int(x) for x in input().split()]
i1 = A.index(1)
ans = 0
tmp = i1
while True:
    if tmp <= 1:
        break
    tmp -= k - 1
    ans += 1
tmp = i1
while True:
    if n <= tmp:
        break
    tmp += k - 1
    ans += 1
print(ans)

Submission status: Wrong Answer

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

min_index = li.index(1)
left = min_index
right = len(li) - left - 1
# print("left", left, "right", right)

count = 0

if (N == K) :
    count = 1
else :
    a = 0
    if (left > 0) :
        count += left // (K-1)
        if (left % (K-1) != 0) :
            count += 1
            a = left % (K-1)

    if (right - a > 0) :
        count += (right - a) // (K-1)
        if ((right - a) % (K-1) != 0) :
            count += 1

print(count)

Submission status: Wrong Answer

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

min_index = li.index(1)
left = min_index
right = len(li) - left - 1
# print("left", left, "right", right)

count = 0

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

    if (right > 0) :
        count += right // (K-1)
        if (right % (K-1) != 0) :
            count += 1

print(count)

Submission status: Wrong Answer

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

min_index = li.index(1)
left = min_index
right = len(li) - left - 1

count = 0

if (left > 0) :
    count += left // (K-1)
    if (left % (K-1) == 1) :
        count += 1

if (right > 0) :
    count += right // (K-1)
    if (right % (K-1) == 1) :
        count += 1

print(count)

Submission status: Wrong Answer

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

min_index = li.index(1)
left = min_index
right = len(li) - left - 1

count = 0

if (left > 0) :
    count += left // 2
    if (left % 2 == 1) :
        count += 1

if (right > 0) :
    count += right // 2
    if (right % 2 == 1) :
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
from collections import Counter

n, k = map(int, input().split())
A = [int(x) for x in input().split()]
# most common value
mcv = Counter(A).most_common()[0][0]
idx = 0
ans = 0
while True:
    if idx >= n:
        break
    if A[idx] == mcv:
        idx += 1
        continue
    idx += k - 1
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(200000000)


# my functions here!

#入力

def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    N,K=pin()
    
    ans=1
    n=N-K
    if n >0:ans+=(n)//(K-1)+1
    print(ans)
        
     
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """4 3
2 3 1 4"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 3
1 2 3"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """8 3
7 3 1 8 4 6 2 5"""
        output = """4"""
        self.assertIO(input, output)
if __name__=="__main__":resolve()

Submission status: Wrong Answer

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

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

mn = 0
for i in range(n):
    mn = min(mn, a[i])

ans = 0

if (k != 1):
    k -= 1

for i in range(0, n, k):
    ans += 1

if n == k + 1 or k == 1:
    ans -= 1

print(ans)

Submission status: Wrong Answer

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

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

mn = 0
for i in range(n):
    mn = min(mn, a[i])

ans = 0

k -= 1

for i in range(0, n, k):
    ans += 1

if n == k + 1:
    ans -= 1

print(ans)

Submission status: Wrong Answer

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

a = list(map(int, input().split()))
k -= 1
ans = n // k

print(ans)

Submission status: Wrong Answer

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

id_of_one = lst.index(1) #リスト内の最小値1のインデックスを取得

left = len(lst[0:id_of_one]) #1より左側にある数列の長さ
right = len(lst[id_of_one+1:]) #1より右側にある数列の長さ
total = left + right

amari = max(left%(k-1),right%(k-1))
total -= amari



counter = 0
while total > 0:
    counter += 1
    total -= k - 1

print(counter)

Submission status: Wrong Answer

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

ans = 1

if(K-1 == 1):
  print(N - 1)
else:
  print(N // (K - 1))
idx = A.index(1)
cnt = 1
right = idx
left = idx
while True:
  for i in range(1, K):
    right += 1
    if(right < len(A)):  
      A[right] = 1
    else:
      left -= 1
      if(0 <= left):
        A[left] = 1
      else:
        print(cnt)
        exit()
  if(left <= 0 and len(A)-1 <= right):
    print(cnt)
    exit()
  else:
    cnt += 1

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)

counter = 0
mn = min(left_length,right_length)
mx = max(left_length,right_length)

mx -= mn % (k-1)

while mn > 0:
    counter += 1
    mn -= k-1

mx -= mn % (k-1)

while mx > 0:
    counter += 1
    mx -= k-1




print(counter)

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)

counter = 0
mn = min(left_length,right_length)
mx = max(left_length,right_length)
total = mn + mx
total -= mn % (k-1)

while total > 0:
    total -= k-1
    counter += 1



print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 1

idx = A.index(1)
cnt = 1
right = idx
left = idx
while True:
  for i in range(1, K):
    right += 1
    if(right < len(A)):  
      A[right] = 1
    else:
      left -= 1
      if(0 <= left):
        A[left] = 1
      else:
        print(cnt)
        exit()
  if(left == 0 and len(A)-1 == right):
    print(cnt)
    exit()
  else:
    cnt += 1

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)
counter = 0


if min(left_length,right_length) < k-1:
    if left_length < right_length:
        right_length -= left_length%(k-1)
    else:
        left_length -= right_length%(k-1)


while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
print(left_length)
right_length = len(lst[id_one:])-1
print(right_length)
counter = 0


if min(left_length,right_length) < k-1:
    if left_length < right_length:
        right_length -= left_length%(k-1)
    else:
        left_length -= right_length%(k-1)


while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

Submission status: Wrong Answer

Solution code:
#C - Minimization
N,K = map(int, input().split())
A = list(map(int, input().split()))
tmp = 0
# for i in range(N):
#     if A[i] == 1:
#         tmp = i+1
#         break

if N % K > 0:
    ans = N//K +N//K
else:
    ans = N//K
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)
counter = 0



while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one+1])-1
right_length = len(lst[id_one:])-1

counter = 0



while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])-1
right_length = len(lst[id_one:])-1

counter = 0



while left_length > 0:
    counter += 1
    left_length -= k-1


while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])-1
right_length = len(lst[id_one:])-1

counter = 0

if left_length > 0:
    left_length -= k
    counter += 1

while left_length > 0:
    counter += 1
    left_length -= k-1

if right_length > 0:
    counter += 1
    right_length -= k

while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
right_length = len(lst[id_one:])

counter = 0

if left_length > 0:
    left_length -= k
    counter += 1

while left_length > 0:
    counter += 1
    left_length -= k-1

if right_length > 0:
    counter += 1
    right_length -= k

while right_length > 0:
    counter += 1
    right_length -= k-1

print(counter)

Submission status: Wrong Answer

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

print(N // (K - 1))

Submission status: Wrong Answer

Solution code:
#解説参照
#前の版のn+k-2をm+k-1に修正
#1の両側調整とか考えたのが間違い
#端から貪欲と変わらない

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

Submission status: Wrong Answer

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

i = a.index(1)

if (i-1)%(k-1)+(n-i)%(k-1)==k-1:##
    print((n-1)//(k-1))
else:
    print((n-1)//(k-1)+1)

Submission status: Wrong Answer

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

i = a.index(1)

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

Submission status: Wrong Answer

Solution code:
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n,k=map(int,input().split())
ans=1
now=k
while now<n:
    n= n-k+1
    ans+=1
    now+=k-1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, k, *nums = map(int, open(0).read().split())
print(math.ceil((n-k)/2)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if k < n:
    ans = 0
    while n > 0:
        n -= k - 1
        ans += 1
else:
    ans = 1
print(ans)

Submission status: Wrong Answer

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

ind = a.index(1)
cnt = k - 1
ans = 0
for i in reversed(range(ind + 1)):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

if n > k:
    cnt = k - 1
for i in range(ind, n):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

print(ans)

Submission status: Wrong Answer

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

ind = a.index(1)
cnt = k - 1
ans = 0
for i in reversed(range(ind)):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

if n > k:
    cnt = k - 1
for i in range(ind, n):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

print(ans)

Submission status: Wrong Answer

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

ind = a.index(1)
cnt = k - 1
ans = 0
for i in reversed(range(ind)):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

for i in range(ind, n):
    cnt -= 1
    if cnt == 0:
        ans += 1
        cnt = k - 1

print(ans)

Submission status: Wrong Answer

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

if k < n:
    left = a.index(1)

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

    right = n - left - 1

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

Submission status: Wrong Answer

Solution code:
S = input().split(" ")
N = int(S[0])
K = int(S[1])
ARR = input().split(" ")



import re
import math

def calculate(n,k,arr):
    miniest = int(min(arr))

    s = "".join(arr)
    brr = re.split(str(miniest)+'{1,}',s)

    counts = 0

    for br in brr:
        counts += math.ceil(len(br) / (k-1))

    return counts

result = calculate(N,K,ARR)

print(result)

Submission status: Wrong Answer

Solution code:
import bisect

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

amin=min(a)
m=bisect.bisect(a,amin)

#for i in range(n):
#    if a[i]==1:
#        m=i+1
        

k1=k-1
#print(m,k1)

if k1==1:
    print(n-1)
else:
    if m==0:
        n2=(n-1)//k1+1
        print(n2)
    elif m==n:
        n2=(n-1)//k1+1
        print(n2)
    else:
        n2=(m-1-1)//k1+1
        n2r=(n2)*k1-(m-1)
        n3=(n-m-1-n2r)//k1+1
#        print("n",n,"m",m,"k1",k1,"n2",n2,"n3",n3)
        print(n2+n3)

Submission status: Wrong Answer

Solution code:
import bisect

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

m=bisect.bisect(a,1)

k1=k-1

if k1==1:
    print(n-1)
else:
    if m==0:
        n2=(n-1)//k1+1
        print(n2)
    elif m==n:
        n2=(n-1)//k1+1
        print(n2)
    else:
        n2=(m-1-1)//k1+1
        n3=(n-m-1)//k1+1
#        print(n,m,k1,"n2",n2,"n3",n3)
        print(n2+n3)

Submission status: Wrong Answer

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

first = a.index(1)

b_num = math.ceil(len(a[:first]) / (k-1))
a_num = math.ceil(len(a[first+1:]) / (k-1))
#print(b_num)
#print(a_num)

print(b_num+a_num)

Submission status: Wrong Answer

Solution code:

import numpy as np
from functools import reduce
from operator import add,sub,mul,truediv
from fractions import gcd

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

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

mini = min(a)
mini_index = a.index(mini)


#if (len(a)-mini_index)%(k-1):ans = (len(a) - mini_index)/(k-1)+1
#else:ans = (len(a) - mini_index)/(k-1)
#
#if ( (mini_index-1)%(k-1)):ans = ans + (mini_index-1)/(k-1)+1
#else:ans = ans + (mini_index-1)/(k-1)

ans = -(-(len(a)-(mini_index+1))//(k-1))
ans = ans + (-(-(mini_index-1)//(k-1)))

#if ((len(a) - mini_index)%(k-1) + (mini_index-1)%(k-1)) <= (k-1):ans = ans -1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

N, K = map(int, input().split())
A = [int(i) for i in input().split()]    
minA = [i for i,a in enumerate(A) if a==1][0]
print(math.ceil(len(A[:minA])/(K-1)) + math.ceil(len(A[minA+1:])/(K-1)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
count = 0
for i in range(0,N,K-1):
  count += 1
  if N == K:
    break
print(count)

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
count = 0
for i in range(0,N,K-1):
  count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
A=list(map(int,input().split()))
ans = 1
N -= K
while N<=0:
  ans += 1
  N -= K-1
print(ans)