TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
#include<bits/stdc++.h>

using namespace std;
char a[15];
int main(){
    scanf("%s", a);
    int lsum = 0, sum = 0;
    for(int i = 0; i < strlen(a); i++){
        lsum += a[i] - '0';
        sum   = sum * 10 + a[i] - '0';
    }
    if(sum % lsum == 0) printf("Yes\n");
    else printf("No\n");
}


s = input()
print(['Yes', 'No'][int(s) % sum(map(int, s)) != 0])

Verdicts: Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
n=input()
s=0
for i in range(len(n)):
  s=s+int(n[i])
print(("No","Yes")[int(n)%s==0]

n=input()
s=0
for i in range(len(n)):
  s=s+int(n[i])
print(("No","Yes")[int(n)%s==0])


Verdicts: Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
n = int(input())
total = 0
for i in range(len(str(n))):
  total += str(n)[i]
if N%total == 0:
  print('Yes')
else:
  print('No')

n = int(input())
total = 0
for i in range(len(str(n))):
  total += int(str(n)[i])
if n%total == 0:
  print('Yes')
else:
  print('No')

Verdicts: Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = list(input())
	
	to = 0
	for i in N:
		to += int(i)
	
	if N % to == 0:
		print("Yes")
	else:
		print("No")
	
	
if __name__ == "__main__":
	main()


# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	N = list(input())
	
	
	to = 0
	NN = ""
	for i in N:
		to += int(i)
		NN += i
	
	if int(NN) % to == 0:
		print("Yes")
	else:
		print("No")
	
	
if __name__ == "__main__":
	main()


Verdicts: Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
s_string = input()
s_charlist = list(s_string)
s_int = int(s_string)
s_sum10 = sum(list(map(int, s_charlist)))
if s_int % s_sum10 == 0:
    print('YES')
else:
    print('NO')

s_string = input()
s_charlist = list(s_string)
s_int = int(s_string)
s_sum10 = sum(list(map(int, s_charlist)))
if s_int % s_sum10 == 0:
    print('Yes')
else:
    print('No')

Verdicts: Wrong Answer

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
N = input()
S = 0
for n in N:
  S += n
N = int(N)
print("Yes" if N%S == 0 else "No")


N = input()
S = 0
for n in N:
  S += n
N = int(N)
print("Yes" if N%S == 0 else "No")

n = input()
N = int(n)
n = list(n)
for i in range(len(n)):
    n[i] = int(n[i])
sum_n = sum(n)
if N%sum_n==0:
    print("Yes")
else:
    print("No")


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
s = input()
a = list(s)[0]
b = list(s)[1]
sn = a + b
sn = int(sn)
s = int(s)

if s % sn == 0:
  print("YES")
else:
  print("NO")

s = input()
l = list(s)
sn = 0
for x in l:
  sn += int(x)

sn = int(sn)
s = int(s)

if s % sn == 0:
  print("Yes")
else:
  print("No")

Verdicts: Wrong Answer

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
a=int(input())
n=list(str(a))
N=map(int,n)
an=0
lena=len(n)
for i in range(lena):
    an += N[i]
if a % an ==0:
    print('Yes')
else:
    print('No')


n=str(input())
a=0
for i in n:
    a += int(i)
if int(n)%a==0:
    print('Yes')
else:
    print('No')


Verdicts: Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
N = input()
ans = 0
for n in N:
  ans += int(n)
if int(N) % ans == 0:
  print("Yes")
else:s
  print("No")

N = input()
ans = 0
for n in N:
  ans += int(n)
if N % ans == 0:
  print("Yes")
else:s
  print("No")

N = input()
ans = 0
for n in N:
  ans += int(n)
if int(N) % ans == 0:
  print("Yes")
else:
  print("No") 

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
N = list(input())
n = int(''.join(N))
sn = 0
for i in N :
    sn += int(i)
if sn % n == 0 :
    print('Yes')
else :
    print('No')

N = list(input())
n = int(''.join(N))
sn = 0
for i in N :
    sn += int(i)
if n % sn == 0 :
    print('Yes')
else :
    print('No')

Verdicts: Wrong Answer

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):

# B - Digit Sums

# B_Digit_Sums.py

N = int(input())
str_N = str(N)

S_N = 0
for i in range(len(str_N)):
    S_N += ( N % (10 ** (i+1)) ) // ( N // (10 ** i) )
print(S_N)



# B - Digit Sums

# B_Digit_Sums.py

N = int(input())
str_N = str(N)

S_N = 0
for i in range(str_N):
    S_N += ( N % (10 ** (i+1)) ) // ( N // (10 ** i) )
print(S_N)



# B - Digit Sums

# B_Digit_Sums.py

N = int(input())
str_N = str(N)

S_N = 0
for i in range(len(str_N)):
    S_N += ( N % (10 ** (i+1)) ) // (10 ** i)

if N % S_N == 0:
    print('Yes')
else:
    print('No')


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Let S(n) denote the sum of the digits in the decimal notation of n. For example, S(101) = 1 + 0 + 1 = 2.  Given an integer N, determine if S(N) divides N.

Submission attempts (in order):
N = input()
n = int(N)
waru = 0
for i in N:
    waru += int(i)
    print(waru)

if((n % waru) == 0):
    print("YES")
else:
    print("NO")

N = input()
n = int(N)
waru = 0
for i in N:
    waru += int(i)
    print(waru)

if((n % waru) == 0):
    print("Yes")
else:
    print("No")


N = input()
n = int(N)
waru = 0
for i in N:
    waru += int(i)

if((n % waru) == 0):
    print("Yes")
else:
    print("No")


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
import math

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

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


for i in range(N):
    if A[i]==1:
        min_a=i+1
        break

x = min_a-1
y = N-min_a


ans=math.ceil(x/(K-1))+math.ceil(y/(K-1))

if x>y:
    x=x-math.ceil(K/2)
    y=y-math.floor(K/2)
else:
    y=y-math.ceil(K/2)
    x=x-math.floor(K/2)
    
ans1=1+math.ceil(x/(K-1))+math.ceil(y/(K-1))

if ans>ans1:
    print(ans1)
else:
    print(ans)

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

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


for i in range(N):
    if A[i]==1:
        min_a=i+1
        break

x = min_a-1
y = N-min_a


ansa=x//(K-1)+y//(K-1)

if x%(K-1)>0:
    ansa=ansa+1
if y%(K-1)>0:
    ansa=ansa+1


#
#if x==y and K%2==1:
#    if (x-kk)%(K-1)==0 and (y-kk)%(K-1)==0:


kk1 = (K-1)//2
kk0 = K-kk1

if x>y:
    x=x-kk0
    y=y-kk1
else:
    x=x-kk1
    y=y-kk0

ansb = 1+x//(K-1)+y//(K-1)

if x%(K-1)>0:
    ansb=ansb+1
if y%(K-1)>0:
    ansb=ansb+1

if ansa>ansb:
    ans=ansb
else:
    ans=ansa

if N==K:
    ans = 1

print(ans)


import math

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

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



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

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n , k = map(int,input().split())
print((n-1)//(k-2)+1)

n , k = map(int,input().split())
print((n-1)//k-2+1)

n , k = map(int,input().split())
l = list(map(int,input().split()))
m = l.index(min(l))
if k <= m:
    ans = (m + 1) //k + 1 + (n -m) // k +1
if k > m:
    o = k - m 
    ans = (k - o) // k + 1

n , k = map(int,input().split())
print((n-2)//(k-1)+1)

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
# print(N, K, A)

answer = N / (K - 1)

print(answer)


import math

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

answer = math.ceil((N - 1)/ (K - 1))

print(answer)


Verdicts: Wrong Answer

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

Submission attempts (in order):
N , K = map(int, input().split(" "))
A = list(map(int, input().split(" ")))
print(ceil((N-1)/(K-1)))

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

Verdicts: Runtime Error

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

Submission attempts (in order):
import sys

def solve(N: int, K: int, A: "List[int]"):
    
    cur = K
    answer = 1
    while K < N:
        cur+=K-1
        answer +=1
    print(answer)
    return


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

if __name__ == '__main__':
    main()


#!/usr/bin/env python3
import sys
import math
def solve(N: int, K: int, A: "List[int]"):
    
    cur = K
    answer = 1 + math.ceil((N-K)/(K-1))
    print(answer)
    return


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

if __name__ == '__main__':
    main()


Verdicts: Time Limit Exceeded

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

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

n, k = map(int, input().split())
a = [int(x) for x in input().split()]
minimum = 10**9
index = -1
for i in range(n):
  if minimum > a[i]:
    index = i
    minimum = a[i]
ans = 1+(i-1)//(k-1)+(n-i-1)//(k-1)
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
N, K = map(int, input().split(" "))
nums = list(input().split(" "))
a = nums.index("1")
l = (a+1) / (K-1)
r = (N-a) / (K-1)
print(l + r)

N, K = map(int, input().split(" "))
if (N-1) / (K-1) == int((N-1) / (K-1)):
  ans = int((N-1)/(K-1))
else:
  ans = int((N-1)/(K-1)) + 1
print(ans)

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1)+1)%(K-1) == 0:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1))-1)
else:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

実装無理
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1))%(K-1) == 0:
    print(math.floor(ind/(K-1)) + math.floor((N-ind-1)/(K-1))+1)
else:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

実装無理
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1)) <= K-1:
    print(math.floor(ind/(K-1)) + math.floor((N-ind-1)/(K-1))+1)
else:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if (ind%(K-1) + (N-ind-1)%(K-1))%(K-1) == 1:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1))-1)
else:
    print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
ind = A.index(1)
if K == 2:
    print(N-1)
else:
    if (ind%(K-1) + (N-ind-1)%(K-1)+1) <= K-1:
        print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1))-1)
    else:
        print(math.ceil(ind/(K-1)) + math.ceil((N-ind-1)/(K-1)))

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

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N, K = map(int, input().split())

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

min_idx = A.index(min(A))

leftnum = min_idx
rightnum = N - (min_idx + 1)
print((leftnum + rightnum) // (K - 1))

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

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

min_idx = A.index(min(A))

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

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

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

min_idx = A.index(min(A))

if K >= N:
    print(1)
else:
    if (n-1)%(k-1):
        print((N - 1) // (K - 1) + 1)
    else:
        print((N - 1)// (K - 1))

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

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

min_idx = A.index(min(A))

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

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

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

Submission attempts (in order):
N,K =[int(i) for i in input().split(' ')]

A = [int(i) for i in input().split(' ')]

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


N,K =[int(i) for i in input().split(' ')]

A = [int(i) for i in input().split(' ')]

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


Verdicts: Runtime Error

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

Submission attempts (in order):
n,k,*_=map(int,open(0).read().split())
print(-~n//-~k)

n,k,*_=map(int,open(0).read().split())
print(~-n//~-k)

a,b=int(input())
for x in input().split():
  print(x)

n,k=map(int,open(0).split())
print(0--~-n//~-k)

n,k=int(input().split());print(0--~-n//~-k)

print(eval('0--~-'+''.join([i if i!=' 'else'//~-'for i in input()])))

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

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

Submission attempts (in order):
n,k=map(int,input().split())
a=list(map(int,input().split()))
one_p=a.index(1)
ans=0
if n!=k:
  ans=ans+(one_p)//(k-1) if (one_p)%(k-1)==0 else ans+(one_p)//(k-1)+1
  ans=ans+(n-one_p)//(k-1) if (n-one_p)%(k-1)==0 else ans+(n-one_p)//(k-1)+1
  if (n-k)//k==0:
    ans=ans-1
else:
  ans=1
print(ans)

n,k=map(int,input().split())
a=list(map(int,input().split()))
one_p=a.index(1)
ans=0
if n!=k:
  ans=ans+(one_p)//(k-1) if (one_p)%(k-1)==0 else ans=ans+(one_p)//(k-1)+1
  ans=ans+(n-one_p)//(k-1) if (n-one_p)%(k-1)==0: else ans=ans+(n-one_p)//(k-1)+1
else:
  ans=1
print(ans)

n,k=map(int,input().split())
a=list(map(int,input().split()))
one_p=a.index(1)
ans=0
if n!=k:
  ans=ans+(one_p)//(k-1) if (one_p)%(k-1)==0 else ans+(one_p)//(k-1)+1
  ans=ans+(n-one_p)//(k-1) if (n-one_p)%(k-1)==0: else ans+(n-one_p)//(k-1)+1
else:
  ans=1
print(ans)

n,k=map(int,input().split())
ans=1
while n>ans*(k-1)+1:
  ans=ans+1
print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

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

Submission attempts (in order):
[N, K] = map(int, input().split())
A = input()
count = 1
while N != 1:
	N = N // K + (1 if N  - N*(N // K) != 0 else 0)
	count = count + 1
print((K**(count - 1) - 1)//(K - 1))


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


Verdicts: Wrong Answer

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

Submission attempts (in order):
n, k = [int(i) for i in input().split()]
input()
if n == k:
    print(1)
    exit()
c = 1
i = 1
while c <= n:
    c += k
    i += 1
print(i)


n, k = [int(i) for i in input().split()]
input()
if n == k:
    print(1)
    exit()
c = 1
i = 1
while c <= n:
    c += k - 1
    i += 1
print(i)

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


Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
N,K = map(int,input().split())
a_list = list(map(int,input().split()))

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

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)

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

min_place = a.index(1) + 1
left = math.ceil((min_place - 1) / (k-1)) 
if left != 0:
  left_lest = (k-1) - (min_place - 1) % (k-1)
else:
  left_lest = 0
right = math.ceil((n - min_place - left_lest) / (k-1))

print(left + right)

import math
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

min_place = a.index(1) + 1
left = math.ceil((min_place - 1) / (k-1)) 
left_lest = (k-1) - (min_place - 1) % (k-1)
right = math.ceil((n - min_place - left_lest) / (k-1))

print(left + right)

import math
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

min_place = a.index(1) + 1
left = math.ceil((min_place - 1) / (k-1)) 
left_lest = 0
if left != 0 and (min_place - 1) % (k-1) != 0:
  left_lest = (k-1) - (min_place - 1) % (k-1)
  
right = math.ceil((n - min_place - left_lest) / (k-1))
print(left + right)

Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):

import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = math.floor((N - 1) / (K - 1))
print(ans)



import math
N, K = map(int, input().split())
A = [int(x) for x in input().split()]
ans = math.ceil((N - 1) / (K - 1))
print(ans)


Verdicts: Wrong Answer

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

Submission attempts (in order):
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
print((N-1)//(K-1))


N,K = list(map(int,input().split()))
A = list(map(int,input().split()))
print((N+K-3)//(K-1))


Verdicts: Wrong Answer

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

Submission attempts (in order):
n,k = map(int,input().split())
A = list(map(int,input().split()))
a = A.index(1)
b = -(-a//(k-1))*(k-1)+1
if n == k:
    print(1)
else:
    print(-(-a//(k-1))-(-(n-b-1)//(k-1)))

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
N, K = map(int,input().split())
print((N-1)//(K-1))

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
print(math.ceil((N-1)/K-1))


    


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


    


Verdicts: Wrong Answer

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

Submission attempts (in order):
a, b = map(int, input().split())
c = b - 1

d = a / c

print(d + 1)

import math
a, b = map(int, input().split())
c = b - 1

d = a / c

print(math.ceil(d)


a, b = map(int, input().split())
c = b - 1

d = a / c

print(d)

import math
a, b = map(int, input().split())
d = (a-1) / (b-1)
print(math.ceil(d))


Verdicts: Wrong Answer

Runtime Error

Wrong Answer

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

Submission attempts (in order):
N,K = map(int,input().split())

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
n,k = map(int,input().split())
A = list(map(int,input().split()))
import math
ans = math.ceil(((n-1)/(k-1))
print(ans)

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



Verdicts: Runtime Error

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

Submission attempts (in order):
nk=input().split()
l=input().split()

nk_i=[int(s) for s in nk]
N=nk_i[0]
K=nk_i[1]

l_i=[int(s) for s in l]

j=l_i.index(1)
j

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


nk=input().split()
l=input().split()

nk_i=[int(s) for s in nk]
N=nk_i[0]
K=nk_i[1]

l_i=[int(s) for s in l]

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
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)

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)


Verdicts: Wrong Answer

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

Submission attempts (in order):
N, K = map(int, input().split())
A = list(map(int, input().split()))

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

import math

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

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

Verdicts: Wrong Answer

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

Submission attempts (in order):
N, K = map(int, input().split())
# perm = list(map(int, input().split()))

# print(N)

# print(perm)

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


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

# print(N)

# print(perm)

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


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

# print(N)

# print(perm)

n = N
ret = 0

n = n - K
ret += 1

while n > 0:
    n = n - (K - 1)
    ret += 1

print(ret)



Verdicts: Wrong Answer

Wrong Answer

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

Submission attempts (in order):
 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)

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

Verdicts: Runtime Error

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

Submission attempts (in order):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    print(A)
    del A[0:K]
print(sum)

N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    print(A)
    del A[0:K]
print(sum)

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

Verdicts: Runtime Error

Runtime Error

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

Submission attempts (in order):
n,k=map(int,input().split())
a=list(map(int,input().split()))
li=[]
import collections
A=collections.Counter(a)
for key in A.keys():
    li.append(key)
x=A[li[0]]    
print(int((n-x)//(k-1)))

    
        

n,k=map(int,input().split())
a=list(map(int,input().split()))
li=[]
import collections
import math
A=collections.Counter(a)
for key in A.keys():
    li.append(key)
x=A[li[0]]
print(math.ceil((n-x)/(k-1)))

    
        




Verdicts: Wrong Answer

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

Submission attempts (in order):
n,m=map(int,input().split())
l=list(map(int,input().split()))
print(-(-((len(l)-m)//(m-1))))

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


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


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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk+k-2
r=n-(chk+1)+k-2
t1=l%(k-1)
t2=r%(k-1)
print(min(l//(k-1)+r//(k-1),((l-t2)//(k-1))+(r//(k-1)), (l//(k-1))+((r-t1)//(k-1))))


n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk+k-2
r=n-(chk+1)+k-2
t1=k-(l%(k-1))
t2=k-(r%(k-1))
print(min(l//(k-1)+r//(k-1),((l-t2)//(k-1)+r//(k-1)), (l//(k-1)+(r-t1)//(k-1))))


n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
print(chk//(k-1)+(n-chk-1)//(k-1))


n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
k-=1
l=chk
r=n-(chk+1)
t1=l%k
t2=r%k
print(min(((l+k-1)//k)+(r//k),((l-t2)//k)+(r//k), (l//k)+((r-t1)//k)))


n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
k-=1
l=chk
r=n-(chk+1)
t1=k-l%k
t2=k-r%k
print(min(((l+k-1)//k)+((r+k-1)//k),((l-t2)//k)+((r+k-1)//k), ((l+k-1)//k)+((r-t1)//k)))


n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
l=chk
r=n-(chk+1)
t1=l%(k-1)
t2=r%(k-1)
print(min(l//(k-1)+r//(k-1),((l-t2)//(k-1))+(r//(k-1)), (l//(k-1))+((r-t1)//(k-1))))


n,k=map(int,input().split())
a=[int(i) for i in input().split()]
chk=a.index(1)
k-=1
l=chk
r=n-chk-1
ans=((l+k-1)//k)+((r+k-1)//k)

if l%k==0:
    t1=0
else:
    t1=k-(l%k)
ans=min(ans,((l+k-1)//k)+((r-t1+k-1)//k))

if r%k==0:
    t2=0
else:
    t2=k-(r%k)
ans=min(ans,((l-t2+k-1)//k)+((r+k-1)//k))
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

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

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

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

Submission attempts (in order):
from math import ceil, floor

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

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

idx = 0
for i in range(N):
    if A[i] == 1:
        idx = i
        break

ans = N
for k in range(K):
    temp = 1
    l = max(idx - k, 0)
    r = min(l + K - 1, N - 1)

    if l == 0:
        num_l = 0
    else:
        num_l = l + 1

    if num_l == K:
        temp += 1
    else:
        temp += ceil(num_l / (K - 1))

    if r == N - 1:
        num_r = 0
    else:
        num_r = N - r

    if num_r == K:
        temp += 1
    else:
        temp += ceil(num_r / (K - 1))

    ans = min(ans, temp)


from math import ceil

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

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


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


Verdicts: Wrong Answer

Accepted