Problem:


Score : 300 points

Problem Statement

There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.

On this sequence, Snuke can perform the following operation:

Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value among the chosen elements.

Snuke would like to make all the elements in this sequence equal by repeating the operation above some number of times.
Find the minimum number of operations required.
It can be proved that, Under the constraints of this problem, this objective is always achievable.

Constraints

2 \leq K \leq N \leq 100000

A_1, A_2, ..., A_N is a permutation of 1, 2, ..., N.

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 ... A_N

Output

Print the minimum number of operations required.

Sample Input 1

4 3
2 3 1 4

Sample Output 1

2

One optimal strategy is as follows:

In the first operation, choose the first, second and third elements. The sequence A becomes 1, 1, 1, 4.

In the second operation, choose the second, third and fourth elements. The sequence A becomes 1, 1, 1, 1.

Sample Input 2

3 3
1 2 3

Sample Output 2

1

Sample Input 3

8 3
7 3 1 8 4 6 2 5

Sample Output 3

4



Sample input:
4 3
2 3 1 4


Sample output:
2

Submission status: Wrong Answer

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

N, K = getNM()
A = getList()
mi = min(A)
miindex = []
for i in range(N):
    if A[i] == mi:
        miindex.append(i)
ans = 1000000
for i in miindex:
    rang = K - 1
    opt1 = (i + rang - 1) // rang
    opt2 = ((N - i - 1) + rang - 1) // rang
    ans = min(ans, opt1 + opt2)
print(ans)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
A = tuple(map(int, input().split()))
idx1 = A.index(1)

lcount = -(-idx1 // (k-1))
rcount = -(-(n - 1 - idx1) // (k-1))
print(lcount + rcount)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math

ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
a = nl()

for i in range(n):
  if a[i]==1:
    x = math.ceil(i/(k-1))
    y = math.ceil((n-i-1)/(k-1))
    ans = x+y
if n==k:
  ans=1
print(ans)

Submission status: Wrong Answer

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
a = nl()
import math
for i in range(n):
  if a[i]==1:
    x = math.ceil(i/(k-1))
    y = math.ceil((n-i-1)/(k-1))
    ans = x+y

print(ans)

Submission status: Wrong Answer

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,k = nm()
a = nl()

m = min(a)

ans=0
cnt=0
for i in range(n):
  cnt+=1
  if cnt == k:
    ans+=1
    cnt=1
    
  if a[i]==m:
    cnt=1
  
if cnt!=1:
  ans+=1 

print(ans)

Submission status: Wrong Answer

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

place_1 = A.index("1")
L = place_1
R = n - L - 1

print(-(-L//(k-1)) + -(-R//(k-1)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
a_list = list(map(int,input().split()))
print((n+k)//k)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int , input().split()))
idx = a.index(1)
l = idx + 1
r = n - idx
if n == k:
    print(1)
    exit()
ln = 1
if l == 1:
    ln = 0
elif l >= k:
    ln = l // (k-1)
rn = 1
if r == 1:
    rn = 0
elif r >= k:
    rn = r // (k-1)

print(ln + rn)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int , input().split()))
idx = a.index(1)
l = idx + 1
r = n - idx
if n == k:
    print(1)
    exit()
ln = 1
if l >= k:
    ln = l // (k-1)
rn = 1
if r >= k:
    rn = r // (k-1)

print(ln + rn)

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
a = list(map(int , input().split()))
idx = a.index(1)
l = idx + 1
r = n - idx
print(max(0,l // (k-1)) + max(0,r // (k-1)))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

if s == 0 or s == n-1:
    print(ceil((n-1)/(k-1)))
else:
    print(ceil((s-1)/(k-1)) + 1 + ceil((n-s-2)/(k-1)))

Submission status: Wrong Answer

Solution code:
from math import ceil

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

if start == 0 or start == n-1:
    print(ceil((n-1)/2))
else:
    print(ceil((start-1)/2) + 1 + ceil((n-start-2)/2))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
if r < l:
    l,r = r,l
if n == k:
    print("1")
elif l <= k-1:
    print(int(math.ceil((r-k+1+l)/(k-1)))+1)
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
if r < l:
    l,r = r,l
if n == k:
    print("1")
elif l < k-1:
    print(int(math.ceil((r-k+1+l)/(k-1)))+1)
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
if r < l:
    l,r = r,l
print(l,r)
if n == k:
    print("1")
elif l < k-1:
    print(int(math.ceil((r-k+1+l)/(k-1)))+1)
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
if r < l:
    l,r = r,l
if n == k:
    print("1")
elif l < k-1:
    print(int(r-k+1+l)+1)
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
if r < l:
    i,r = r,l
if n == k:
    print("1")
elif l < k-1:
    print(int(r-k+1+l)+1)
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
if n == k:
    print("1")
else:
    print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))

Submission status: Wrong Answer

Solution code:
import math
n,k = map(int,input().split())
ls = list(map(int,input().split()))
a = min(ls)
i = ls.index(a)
l = i
r = n - i - 1
print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Len, Split = map(int, input().split())
_res = Len % (Split-1)

if _res:
    res = int((Len / (Split - 1)) + 1)
    print(res)
else:
    res = int(Len / (Split - 1))
    print(res)

Submission status: Wrong Answer

Solution code:
Len, Split = map(int, input().split())
_res = Len % Split
if _res:
    res = int((Len / Split) + 1)
    print(res)
else:
    res = int(Len / Split)
    print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
Len, Split = map(int,input().split())
Nums = map(int,input().split())
print(Len/(Split-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

x = n//(k-1) + 1
print(x)

Submission status: Wrong Answer

Solution code:
import math

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

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

min_index = a.index(min(a))

left_count = min_index

right_count = n - min_index - 1

print( math.ceil(left_count / (k-1)) + math.ceil(right_count / (k-1)) )

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1

#############
# Main Code #
#############

N,K = IL()
A = IL()
p = A.index(1)

P(-(-p//(K-1))+-(-(N-p-1)//(K-1)))

Submission status: Wrong Answer

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n = n//a
    count += 1
  if a**count == n:
    return count
  else:
    return count+1

#############
# Main Code #
#############

N,K = IL()
A = IL()
p = A.index(1)

P(-(-p//(K-1))+-(-(N-p)//(K-1)))

Submission status: Wrong Answer

Solution code:
import math

def read_ints():
    return[int(i) for i in input().split()]

def main():
    n, k = read_ints()
    print(math.ceil(n / k))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	i = a.index(min(a))
	if k - 1 > i:
		v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1
	else:
		v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1))
	print(v)
resolve()

Submission status: Wrong Answer

Solution code:
import math
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	i = a.index(min(a))
	v = math.ceil(i/(k-1)) + math.ceil((n-1-i)/(k-1))
	print(v)
resolve()

Submission status: Wrong Answer

Solution code:
import math
def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	i = a.index(min(a))
	v = math.ceil(i/2) + math.ceil((n-1-i)/2)
	print(v)
resolve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))
######################################################################################################
def main():
    N,K=inputintlist()
    A=inputintlist()
    K-=1
    ans=N//K
    if N%K>1:ans+=1
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import re
import math
from collections import defaultdict
from collections import deque
from fractions import Fraction
import itertools
from copy import deepcopy
import random
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
#@lru_cache(maxsize=None)
readline=sys.stdin.readline
sys.setrecursionlimit(2000000)
#import numpy as np
alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_pow(a,b):#aはbの累乗数か
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def get_primes(n,type="int"):
    if n==0:
        if type=="int":return []
        else:return [False]
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=""):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def pm(x):
    return x//abs(x)
def inputintlist():
    return list(map(int,input().split()))
######################################################################################################
def main():
    N,K=inputintlist()
    A=inputintlist()
    K-=1
    ans=N//K
    if N%K!=1:ans+=1
    print(ans)
main()

Submission status: Wrong Answer

Solution code:
import math


def main():
    N, K = list(map(int, input().split(' ')))
    A = list(map(int, input().split(' ')))
    index_one = A.index(1)
    min_cnt = N
    for left_index in (index_one - (K - 1), index_one + 1):
        right_index = left_index + (K - 1)
        cnt = math.ceil((left_index + 1) / (K - 1)) + math.ceil((N + 1 - right_index) / (K - 1))
        min_cnt = min([min_cnt, cnt])
    print(min_cnt)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

ans = math.ceil(n/k)

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
for i in range(n):
    if lis[i]==1:
        one=i+1
#print(one)
ans=ceil((one-1)/(k-1))+ceil((n-one)/(k-1))
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
for i in range(n):
    if lis[i]==1:
        one=i+1
#print(one)
ans=ceil((one-1)/2)+ceil((n-one)/2)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil

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

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

i = a_list.index(1)
ans = ceil(i / (k - 1)) + ceil((n - 1 - i) / (k - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N,K = (int(x) for x in input().split())
A = list(map(int, input().split()))
if N == K:
    print('1')
else:
    m = A.index(1)
    a = math.floor((m+1)/(K-1))
    b = math.floor((N-a*(K-1))/(K-1))
    print(a+b)

Submission status: Wrong Answer

Solution code:
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(ceil((l)/(K-1))+ ceil((r-1)/(K-1)))

Submission status: Wrong Answer

Solution code:
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)))

Submission status: Wrong Answer

Solution code:
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(ceil((l)/(K-1))+ ceil((r)/(K-1)))

Submission status: Wrong Answer

Solution code:
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(ceil((l-1)/(K-1))+ ceil((r-1)/(K-1)))

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9+7
MAX = 10**18
MIN = -10**18

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    if a[i] == 1:
        start = i
        break
start += 1
r = n - start + 1
l = start
print(r//(k-1) + l//(k-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

l = a.index(1)
r = n - l - 1

if n == k:
    print(1)
else:
    ans = math.ceil(l/(k-1))+ math.ceil(r/(k-1))
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0
for i in range(0, n, k - 1):
    count += 1
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
if N == K:
    print(1)
    quit()
A = tuple(map(int, input().split()))
left = A.index(1)
right = N - left - 1
div_l, rem_l = divmod(left, K - 1)
div_r, rem_r = divmod(right, K - 1)
print(div_l + bool(rem_l) + div_r + bool(rem_r))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
A = tuple(map(int, input().split()))
left = A.index(1)
right = N - left - 1
div_l, rem_l = divmod(left, K - 1)
div_r, rem_r = divmod(right, K - 1)
print(div_l + bool(rem_l) + div_r + bool(rem_r))