TnT/Multi_CodeNet4Repair huggingface dataset:
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 numpy as np
#import pdb

tmp = list(map(int, input().strip().split(' ')))
N = tmp[0]
K = tmp[1]
A = list(map(int, input().strip().split(' ')))

A = np.asarray(A)
pos = np.argmin(A)

left = pos
right = N - pos - 1

st_list = [x for x in range(max(0, pos - K + 1), min(pos + 1, N))]

cnt = np.inf
for st in st_list:
    ed = st + K - 1
    left = st
    right = N - ed - 1
    left_count = np.ceil(left / (K-1))
    right_count = np.ceil(right / (K-1))
    if cnt > (left_count + right_count):
        cnt = left_count + right_count

print(cnt)


import numpy as np
#import pdb

tmp = list(map(int, input().strip().split(' ')))
N = tmp[0]
K = tmp[1]
A = list(map(int, input().strip().split(' ')))

A = np.asarray(A)
pos = np.argmin(A)

left = pos
right = N - pos - 1

st_list = [x for x in range(pos - K + 1, pos + 1)]

cnt = np.inf
for st in st_list:
    ed = st + K - 1
    left = st
    right = N - ed - 1
    left_count = np.ceil(left / (K-1))
    right_count = np.ceil(right / (K-1))
    if cnt > (left_count + right_count):
        cnt = left_count + right_count

print(cnt)

import numpy as np
#import pdb

tmp = list(map(int, input().strip().split(' ')))
N = tmp[0]
K = tmp[1]
A = list(map(int, input().strip().split(' ')))

A = np.asarray(A)
pos = np.argmin(A)

left = pos
right = N - pos - 1

st_list = [x for x in range(max(0, pos - K + 1), min(pos + 1, N))]

cnt = np.inf
for st in st_list:
    ed = st + K - 1
    left = st
    right = N - ed - 1
    left_count = np.ceil(left / (K-1))
    right_count = np.ceil(right / (K-1))
    if cnt > (left_count + right_count):
        cnt = left_count + right_count

print(cnt.astype(np.uint64))

import numpy as np
import math
#import pdb

tmp = list(map(int, input().strip().split(' ')))
N = tmp[0]
K = tmp[1]
A = list(map(int, input().strip().split(' ')))

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


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

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

import math
n,k=map(int,input().split())
print(math.ceil((n-k)/(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):
n, k = map(int, input().split())
a = (list)(map(int, input().split()))

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


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

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


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

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


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

# print(-(-(n-1)//(k-1)))
print((n - 1 + (k - 2)) // (k-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 = list(map(int, input().split()))
A = list(map(int, input().split()))

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

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

import math
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 math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N - 1) // (K - 1)))

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

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

b = a.index(1) 
if b < k-1:
    b += k-1 -b
if b > (n-1) -(k-1):
    b -= b - (k-1)
c,d = divmod(b,k-1)
ans = c
rem = d
if d != 0:
    ans +=1
e = n-1 -b
c,d = divmod(e,k-1)
ans += c
if d != 0:
    ans +=1
if rem + d <= k-1 and rem != 0 or d != 0:
    ans -=1
print(ans)


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

b = a.index(1) 
if b < k-1:
    b += k-1 -b
if b > (n-1) -(k-1):
    b -= b - (k-1)
c,d = divmod(b,k-1)
ans = c
rem = d
if d != 0:
    ans +=1
e = n-1 -b
c,d = divmod(e,k-1)
ans += c
if d != 0:
    ans +=1
if rem + d <= k-1:
    ans -=1
print(ans)


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

b = a.index(1) 
ans = 0
b -= (k-1)
if b < 0:
    b = a.index(1) + abs(b)
if b > n-1 -(k-1):
    b -= b- (k-1)
c,d = divmod(b,k-1)
ans += c
if d != 0:
    ans +=1
e,f = divmod(n-1 - b,k-1)
ans += e
if f != 0:
    ans +=1
if d != 0 and f != 0 and d + f <= k-1:
    ans -=1
print(ans)

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())
_ = input()
count = n // (k - 1)
if n % k == 1:
    count -= 1
print(count)

(n, k) = map(int, input().split())
_ = input()
count = 0

while n > k:
    n -= k - 1
    count += 1

count += 1
print(count)

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 sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
left = data.index(1)
right = N - data.index(1) - 1
ans = (left // (K-1)) + (right // (K-1)) + 2
print(ans)

from sys import stdin
import math
N,K = [int(x) for x in stdin.readline().rstrip().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):
import math
n, k = map(int,input().split())
input()
print((n-1)/(k-1), math.ceil((n - 1)/(k - 1)))


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


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


import math
n, k = map(int,input().split())
input()
print(math.ceil((n-1)/(k-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):
from math import ceil

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

idx = ll.index(1)

l, r = idx, N-idx
print(l, r)
print(ceil((l)/(K-1))+ ceil((r-1)/(K-1)))

from math import ceil

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

print(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())
A = list(map(int, input().split()))
m = min(A)
res = 0
for i in range(N):
    min_num = i
    if m == A[i]:
        break
    
        
n1 = min_num 
n2 = N - min_num - 1

if n1 == 0:
    res = math.ceil(n2/2)
elif n2 == 0:
    res = math.ceil(n1/2)
else:
    res = math.ceil(n1/2) + math.ceil(n2/2)
    
print(res)

import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = min(A)
res = 0

min_num = A.index(m)
  
n1 = min_num 
n2 = N - min_num - 1

if K < min(n1, n2):
    if n1 != n2:
        res = math.ceil(n1/(K-1)) + math.ceil(n2/(K-1))
    else:
        res = math.ceil((n1-1)/(K-1)) + math.ceil((n2-1)/(K-1)) + 1
else:
    res = math.ceil((max(n1, n2) - (K - min(n1, n2)))/(K-1)) + 1

print(res)

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

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

if tmp%(K - 1) != 0:
    ans += 1

print(ans)

Verdicts: 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):
# -*- coding: utf-8 -*-

import math


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


x = A.index(1)
y = N - x - 1
ans = math.ceil(x / (K - 1)) + \
    math.ceil((y - ((K - 1) - x % (K - 1))) / (K - 1))


print(ans)


# -*- coding: utf-8 -*-

import math


def get_input() -> tuple:
    
    
    N, K = list(map(int, input().split()))
    A = list(map(int, input().split()))

    return N, K, A


def main(N: int, K: int) -> None:
    
    
    ans = math.ceil((N - 1) / (K - 1))

    
    print(ans)


if __name__ == "__main__":
    
    N, K, A = get_input()

    
    main(N, K)


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(_) for _ in input().split()]

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

idx = a.index(1)
num_l = idx
num_r = n - idx - 1
print(num_l, num_r)

if num_l == 0 or num_r == 0:
    print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))
elif num_l < k-1:
    print(math.ceil(num_l / (k - 1)) + math.ceil((num_r - k + 1 + num_l) / (k - 1)))
elif num_r < k-1:
    print(math.ceil((num_l - k + 1 + num_r) / (k - 1)) + math.ceil(num_r / (k - 1)))
else:
    print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))


import math
n, k = map(int, input().split())
a = [int(_) for _ in 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):
import sys

def solve(n, k, as):
        return n/(k-1)

def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_n, str_k] = line.split(' ')
    line = sys.stdin.readline().rstrip()
    as = line.split(' ')
    return (int(str_n), int(str_k), [int(a) for a in as])

def main():
    n, k, as = readQuestion()
    answer = solve(n, k, as)
    print(answer)
    
if __name__ == '__main__':
    main()

import sys

def solve(n, k, as1):
    if (n-1)%(k-1)==0:
        return (n-1)//(k-1)
    else:
        return (n-1)//(k-1)+1

def readQuestion():
    line = sys.stdin.readline().rstrip()
    [str_n, str_k] = line.split(' ')
    line = sys.stdin.readline().rstrip()
    as1 = line.split(' ')
    return (int(str_n), int(str_k), [int(a) for a in as1])

def main():
    n, k, as1 = readQuestion()
    answer = solve(n, k, as1)
    print(answer)
    
if __name__ == '__main__':
    main()

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


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


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

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

print(Ans)

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

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

print(Ans)

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

if N == K:
    Ans = 1
elif K == 2:
    Ans = N -1
else:
    if N%(K-1)==0:
        Ans = Ans = N//(K-1)
    else:
         Ans = N//(K-1) + 1
            
e = A.index('1') 
if  e < K or N-e <K:
    Ans = Ans + 1
print(Ans)

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

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

print(Ans)


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):
from math import ceil
n,k=map(int,input().split())
print(ceil(n-1/k-1))

from math import ceil
n,k=map(int,input().split())
print(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):



using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    std::vector<char> a(n);

    for (int i =0;i<n;i++)
        cin >> a[i];
    int ans =-(-n/(k-1));
    cout << ans<<endl;


}

n,k=map(int,input().split())
a=list(map(int,input().split()))
n=n-k
print(-(-n//(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().split())

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

min_A = min(A)


ind1 = A.index(1)
len1 = len(A) -ind1
len2 = ind1 + 1
print((len1-1)//(K-1)-1+1 + (len2-1)//(K-1)-1+1)


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

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

min_A = min(A)


ind1 = A.index(1)
len1 = N -ind1
len2 = ind1 + 1

r1= 0
if (len1-1)%(K-1) != 0:
    r1 = 1

r2= 0
if (len2-1)%(K-1) != 0:
    r2 = 1
d = 0



ans1 = (len1-1)//(K-1)+r1 + (len2-1)//(K-1)+r2

ans=[]
ans.append(ans1)
for i in range(1, K):
    ans2 = 0
    r3= 0
    if (len1-i-1)%(K-1) != 0:
        r3 = 1

    r4= 0
    if (len2-((K-1)-i)-1)%(K-1) != 0:
        r4 = 1
    ans2 = (len1-i-1)//(K-1)+r3 + (len2-((K-1)-i)-1)//(K-1)+r4 + 1
    ans.append(ans2)
    print(i, ans2)


print(min(ans))


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

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

min_A = min(A)


ind1 = A.index(1)
len1 = N -ind1
len2 = ind1 + 1

r1= 0
if (len1-1)%(K-1) != 0:
    r1 = 1

r2= 0
if (len2-1)%(K-1) != 0:
    r2 = 1
d = 0



ans1 = (len1-1)//(K-1)+r1 + (len2-1)//(K-1)+r2

ans=[]
ans.append(ans1)
for i in range(1, K):
    ans2 = 0
    r3= 0
    if (len1-i-1)%(K-1) != 0:
        r3 = 1

    r4= 0
    if (len2-((K-1)-i)-1)%(K-1) != 0:
        r4 = 1
    ans2 = (len1-i-1)//(K-1)+r3 + (len2-((K-1)-i)-1)//(K-1)+r4 + 1
    ans.append(ans2)



print(min(ans))


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):
3 3
1 2 3

def solve():
    n,k = map(int, input().split())
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

if __name__ == '__main__':
    print(solve())

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 = list(map(int, input().split()))
a = list(map(int, input().split()))
print((n-k+1)//(n-1)+1)

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()))
c = 0
while n > 0:
  if c == 0:
    n -= k
  else:
    n -= k-1
  c += 1
print(c)

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())
ans = (N-1)//(K-1)
print(ans)

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

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

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

print((N-1)//(K-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):
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
min_in = A.index(1)

left = len(A[0:min_in])

right = len(A[min_in+1:])
#print(left,  right)
if N ==K:
    ans = 1
    
else:
    if (min(left, right) + 1) < K:
        ans += 1
        tuyoi = len(A-K)
        
        ans += tuyoi//K
        
        if tuyoi % K !=0:
            ans +=1
    
    else:
        if left != 0:
            ans += left//(K-1)
            
            if left%(K-1) != 0:
                ans += 1
        
        if right != 0:
            ans += right//(K-1)
            
            if right%(K-1) != 0:
                ans += 1
print(ans)

N, K = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
min_in = A.index(1)

left = len(A[0:min_in])

right = len(A[min_in+1:])

if N ==K:
    ans = 0
    
else:
    if (min(left, right) + 1) < K:
        ans += 1
        tuyoi = len(A-K)
        
        ans += tuyoi//K
        
        if tuyoi % K !=0:
            ans +=1
    
    else:
        if left != 0:
            ans += left//(K-1)
            
            if left%(K-1) != 0:
                ans += 1
        
        if right != 0:
            ans += right//(K-1)
            
            if right%(K-1) != 0:
                ans += 1
print(ans)

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)

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,m=map(int,input().split())
l=list(map(int,input().split()))
min=l[0]
index=0
for i in range(n):
  if min>l[i]:
    min=l[i]
    index=i
index+=1
index2=n-index
sum=0
sum+=index2//m+1
index3=index-1
sum+=index3//m+1
  

n,m=map(int,input().split())
l=list(map(int,input().split()))
if (n-1)%(m-1)==0:
  print((n-1)//(m-1))
else:
  print((n-1)//(m-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):






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



n,k = 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()))
idx=a.index(1)
print((n-idx)//(k-1)+(1 if (n-idx)%(k-1)!=0 else 0)+(idx+1)//(k-1)+(1 if (idx+1)%(k-1)!=0 else 0))


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

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


import math
N, K = map(int, input().split())
print( 1 + math.ceil((N-K) / (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())
list = []
for i in range(N):
    list.append(int(input()))

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

N,K = map(int, input().split())
print(-(-(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):
n,k=map(int,input().split())
a=list(map(int,input().split()))
count=1
n-k
while(n>0):
    n-(k-1)
    count+=1
print(count)


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

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())
As = list(map(int,input().split()))
print((N-1)//(K-1))

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

import numpy as np 
ans = np.ceil((N-1)/(K-1))
print(int(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)

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

a = (N-2)//(K-1)+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):
import math
N, K = map(int, input().split())
print(math.ceil((N-K)/(K-1)))

import math
N, K = 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):

import math

n , k = map(int, input().split())
b = list(map(int,input().split()))
cnt = 1
i = 0
for t in b:
    if t == 1:
        i = cnt
        break
    cnt += 1

result = math.ceil((i-1)/(k-1)) + math.ceil((n-i)/(k-1))
if ((i-1)/(k-1) - math.floor((i-1)/(k-1))) + ((n-i)/(k-1) - math.floor((n-i)/(k-1))) <= 1:
    result -= 1

print(result)



import math

n , k = map(int, input().split())
b = list(map(int,input().split()))
cnt = 1
i = 0
for t in b:
    if t == 1:
        i = cnt
        break
    cnt += 1

result = math.ceil((i-1)/(k-1)) + math.ceil((n-i)/(k-1))
if ((i-1)/(k-1) - math.floor((i-1)/(k-1))) != 0 and ((n-i)/(k-1) - math.floor((n-i)/(k-1))) != 0 and (((i-1)/(k-1) - math.floor((i-1)/(k-1))) + ((n-i)/(k-1) - math.floor((n-i)/(k-1)))) <= 1:
    result -= 1

print(result)


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())
l = list(map(int, input().split()))
index = l.index(1) + 1

ans = 0

if index != 1:
    p = index - K
    ans += 1
    if p < 0:
        index = K
    p += 1
    while p > 0:
        p = p - K
        ans += 1

while index < N:
    index = index + (K - 1)
    ans += 1

print(ans)


N, K = map(int, input().split())
l = list(map(int, input().split()))
index = l.index(1) + 1

ans = 0

if index != 0:
    p = index - K
    ans += 1
    if p < 0:
        index = K
    p += 1
    while p > 0:
        p = p - K
        ans += 1

while index < N:
    index = index + (K - 1)
    ans += 1

print(ans)


N = int(input())
K = int(input())
l = list(map(int, input().split()))
index = l.index(1)

ans = 0
if index != 0:
    p = index - K + 1
    ans += 1
    if p < 0:
        index = index + (-1 * p)
    elif p > 0:
        while p > 0:
            p = p - K + 1
            ans += 1
if index < (N - 1):
    ans += 1
    index = index + K - 1
    while index < (N - 1):
        index = index + K - 1
        ans += 1

print(ans)

from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))

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


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

import math
n, k = map(int, input().split())
a = list(map(int, input().split()))
x = a.index(1)
#if x % (k-1) + (n-k-1) % (k-1) > k-1:
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):
import math



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

print(ans)


import math

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

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

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):
# -*- 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 ):
        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 = '''\
# 10 3
# 7 3 2 1 1 1 1 5 5 5\
# '''

# 
# 2. use stdin

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

# -*- 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\
#'''

# 
# 2. use stdin

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

#
# solve !!
#
solve(lines)

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())
TMP=K
ANS=1
if N <= K:
  ANS=1
else:
  TMP+=(K-1)
  ANS+=1
  if N <= K:
    break
print(ANS)


N,K=map(int,input.split())
TMP=K
ANS=1
if N =< K:
  ANS=1
else:
  TMP=(K-1)
  ANS+=1
  if N <= K:
    break
print(ANS)


N,K=map(int,input.split())
TMP=K
ANS=1
if N <= K:
  ANS=1
else:
  TMP=(K-1)
  ANS+=1
  if N <= K:
    break
print(ANS)


N,K=map(int,input().split())
TMP=K
ANS=1
if N <= K:
  ANS=1
else:
  while True:
    TMP+=(K-1)
    ANS+=1
    if N <= TMP:
      break
print(ANS)

Verdicts: 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()))
x = a.index(1)
left = x
right = n - x - 1

ans = n
for i in range(k):
    if left < i:
        continue
    a = left - i + 1
    if right - k + 2 + i < 0:
        continue
    b = right - k + 2 + i
    print(a, b)
    w = a//(k-1) + b//(k-1)
    ans = min(ans, w)
print(ans + 1)



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


def ceil(x, y):
    if x % y == 0:
        return x // y
    else:
        return x // y + 1


print(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())
a=len(list(map(int,input().split())))
print((n-k-3)//(k-1))

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

Verdicts: Wrong Answer

Accepted