problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 262k
1.05M
| problem_description
stringlengths 48
1.55k
| codes
stringlengths 35
98.9k
| status
stringlengths 28
1.7k
| submission_ids
stringlengths 28
1.41k
| memories
stringlengths 13
808
| cpu_times
stringlengths 11
610
| code_sizes
stringlengths 7
505
|
---|---|---|---|---|---|---|---|---|---|---|
p03317 | u111555888 | 2,000 | 1,048,576 | 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. | [' N,K=map(int,input().split())\na=list(map(int,input().split()))\nindex=a.index(1)\nl=index\nr=index\ncnt=0\nif index<=(N//2-1 if N%2==0 else N//2):\n while l!=0:\n if cnt==0:\n if l-K+1<0:\n r=K-1\n l=max(0,l-K+1)\n cnt+=1\n while r!=N-1:\n r=min(N-1,r+K-1)\n cnt+=1\n print(cnt)\nelse:\n while r!=N-1:\n if cnt==0:\n if r+K-1>N-1:\n l=N-K\n r=min(N-1,r+K-1)\n cnt+=1\n while l!=0:\n l=max(0,l-K+1)\n cnt+=1\n print(cnt)', 'N,K=map(int,input().split())\nif (N-1)%(K-1)==0:\n print((N-1)//(K-1))\nelse:\n print((N-1)//(K-1)+1)'] | ['Runtime Error', 'Accepted'] | ['s540850718', 's049388067'] | [2940.0, 3060.0] | [17.0, 16.0] | [453, 99] |
p03317 | u115682115 | 2,000 | 1,048,576 | 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. | ['N,K = map(int,input().rstrip().split())\nA = list(map(int,input().rstrip().split()))\nsum =0\nwhile len(A)>=2:\n sum+=1\n A.insert(K,min(A[:K]))\n print(A)\n del A[0:K]\nprint(sum)', 'N,K = map(int,input().rstrip().split())\nA = list(map(int,input().rstrip().split()))\nsum =0\nwhile len(A)>=2:\n sum+=1\n A.insert(K,min(A[:K]))\n print(A)\n del A[0:K]\nprint(sum)', 'import math\nN,K = map(int,input().rstrip().split())\nprint(math.ceil((N-1)/(K-1)))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s264292270', 's907780782', 's026818332'] | [141196.0, 141224.0, 3060.0] | [1646.0, 1647.0, 17.0] | [184, 184, 81] |
p03317 | u116233709 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na=list(map(int,input().split()))\nli=[]\nimport collections\nA=collections.Counter(a)\nfor key in A.keys():\n li.append(key)\nx=A[li[0]] \nprint(int((n-x)//(k-1)))\n\n \n ', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nli=[]\nimport collections\nimport math\nA=collections.Counter(a)\nfor key in A.keys():\n li.append(key)\nx=A[li[0]]\nprint(math.ceil((n-x)/(k-1)))\n\n \n \n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s630300297', 's295186521'] | [18936.0, 19808.0] | [70.0, 67.0] | [206, 222] |
p03317 | u123745130 | 2,000 | 1,048,576 | 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. | ['n,m=map(int,input().split())\nl=list(map(int,input().split()))\nprint(-(-((len(l)-m)//(m-1))))', 'n,m=map(int,input().split())\nl=list(map(int,input().split()))\nprint(-(-(len(l)-m)//(m-1)))\n', 'n,m=map(int,input().split())\nl=list(map(int,input().split()))\nprint(-(-int((len(l)-m)//(m-1))))\n', 'n,m=map(int,input().split()) \nl=list(map(int,input().split())) \nprint(-(-(len(l)-m)//(m-1))+1) '] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s547499891', 's677341158', 's870861714', 's027574903'] | [13880.0, 13812.0, 13880.0, 13880.0] | [41.0, 41.0, 40.0, 39.0] | [92, 91, 96, 95] |
p03317 | u123756661 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nchk=a.index(1)\nl=chk+k-2\nr=n-(chk+1)+k-2\nt1=l%(k-1)\nt2=r%(k-1)\nprint(min(l//(k-1)+r//(k-1),((l-t2)//(k-1))+(r//(k-1)), (l//(k-1))+((r-t1)//(k-1))))\n', 'n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nchk=a.index(1)\nl=chk+k-2\nr=n-(chk+1)+k-2\nt1=k-(l%(k-1))\nt2=k-(r%(k-1))\nprint(min(l//(k-1)+r//(k-1),((l-t2)//(k-1)+r//(k-1)), (l//(k-1)+(r-t1)//(k-1))))\n', 'n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nchk=a.index(1)\nprint(chk//(k-1)+(n-chk-1)//(k-1))\n', 'n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nchk=a.index(1)\nk-=1\nl=chk\nr=n-(chk+1)\nt1=l%k\nt2=r%k\nprint(min(((l+k-1)//k)+(r//k),((l-t2)//k)+(r//k), (l//k)+((r-t1)//k)))\n', 'n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nchk=a.index(1)\nk-=1\nl=chk\nr=n-(chk+1)\nt1=k-l%k\nt2=k-r%k\nprint(min(((l+k-1)//k)+((r+k-1)//k),((l-t2)//k)+((r+k-1)//k), ((l+k-1)//k)+((r-t1)//k)))\n', 'n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nchk=a.index(1)\nl=chk\nr=n-(chk+1)\nt1=l%(k-1)\nt2=r%(k-1)\nprint(min(l//(k-1)+r//(k-1),((l-t2)//(k-1))+(r//(k-1)), (l//(k-1))+((r-t1)//(k-1))))\n', 'n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nchk=a.index(1)\nk-=1\nl=chk\nr=n-chk-1\nans=((l+k-1)//k)+((r+k-1)//k)\n\nif l%k==0:\n t1=0\nelse:\n t1=k-(l%k)\nans=min(ans,((l+k-1)//k)+((r-t1+k-1)//k))\n\nif r%k==0:\n t2=0\nelse:\n t2=k-(r%k)\nans=min(ans,((l-t2+k-1)//k)+((r+k-1)//k))\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s063334385', 's401288351', 's533197760', 's775309544', 's828151513', 's919091839', 's310947082'] | [13880.0, 13880.0, 13880.0, 13880.0, 13880.0, 13880.0, 13812.0] | [44.0, 44.0, 44.0, 46.0, 44.0, 45.0, 45.0] | [213, 217, 115, 188, 210, 205, 309] |
p03317 | u131411061 | 2,000 | 1,048,576 | 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. | ['N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nif (N-1)%(K-1) == 0:\n print(N-1//K-1)\nelse:\n print(N-1//K-1 + 1)', 'N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nif (N-1)%(K-1) == 0:\n print((N-1)//(K-1))\nelse:\n print((N-1)//(K-1) + 1)'] | ['Wrong Answer', 'Accepted'] | ['s055101333', 's480594846'] | [13880.0, 14008.0] | [41.0, 39.0] | [137, 145] |
p03317 | u137542041 | 2,000 | 1,048,576 | 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. | ['from math import ceil, floor\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nif N == K:\n print(1)\n exit()\n\nidx = 0\nfor i in range(N):\n if A[i] == 1:\n idx = i\n break\n\nans = N\nfor k in range(K):\n temp = 1\n l = max(idx - k, 0)\n r = min(l + K - 1, N - 1)\n\n if l == 0:\n num_l = 0\n else:\n num_l = l + 1\n\n if num_l == K:\n temp += 1\n else:\n temp += ceil(num_l / (K - 1))\n\n if r == N - 1:\n num_r = 0\n else:\n num_r = N - r\n\n if num_r == K:\n temp += 1\n else:\n temp += ceil(num_r / (K - 1))\n\n ans = min(ans, temp)\n', 'from math import ceil\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nif N == K:\n print(1)\n exit()\n\n\nprint(ceil((N - K) / (K - 1)) + 1)\n'] | ['Wrong Answer', 'Accepted'] | ['s805158266', 's343630986'] | [20316.0, 20508.0] | [97.0, 50.0] | [640, 165] |
p03317 | u138486156 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nif n == k:\n print(1)\n exit()\n\nidx = a.index(1)\n\nif idx < (n//2):\n a = idx//(k-1)\nelse:\n a = (n-idx-1)//(k-1)\n\nm = n - k - (k-1)*a\n\nif m // (k-1):\n b = m//(k-1)+1\nelse:\n b = m//(k-1)\n\nprint(a+1+b)\n\n', 'from collections import deque\nk = int(input())\n\ndigsum = lambda x: sum(map(int, list(str(x))))\ndignorm = lambda x: x/digsum(x)\n\nn = 1\norder = 1\nwhile k > 0:\n print(n)\n k -= 1\n if dignorm(n+10**(order-1)) > dignorm(n+10**order):\n order += 1\n n += 10**(order-1)\n\n', 'from math import ceil\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(ceil((n-k)/(k-1)) + 1)\n'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s101490650', 's655840158', 's113817952'] | [13880.0, 3316.0, 13812.0] | [45.0, 20.0, 40.0] | [285, 280, 121] |
p03317 | u138537142 | 2,000 | 1,048,576 | 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. | ["info = list(map(int, input().split(' ')))\narray = list(map(int, input().split(' ')))\n\nprint((info[0]-1)//(info[1]-1))", "info = list(map(int, input().split(' ')))\narray = list(map(int, input().split(' ')))\n\nif info[1] == info[0]:\n print(1)\nelif info[1] == 2:\n print(info[0]-1)\nelif info[0]//(info[1]-1)==1:\n print(2)\nelse:\n print((info[0]-1)//(info[1]-1))", "info = list(map(int, input().split(' ')))\narray = list(map(int, input().split(' ')))\n\nprint((info[0]-1+info[1]-2)//(info[1]-1))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s728101376', 's744808534', 's185794221'] | [13812.0, 13880.0, 13812.0] | [39.0, 39.0, 40.0] | [117, 246, 127] |
p03317 | u140697185 | 2,000 | 1,048,576 | 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. | ['import math\nN,K = map(int , input().split())\nA = list(map(int , input().split()))\n\nleft_num = A.index(1)\nright_num = N-left_num-1\nprint(left_num)\nprint(right_num)\n\nans = math.ceil(left_num/(K-1))+math.ceil(right_num/(K-1))\nprint(ans)', 'import math\nN,K = map(int , input().split())\nA = list(map(int , input().split()))\n\nans = math.ceil((N-1)/(K-1))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s234221366', 's274653095'] | [13812.0, 13812.0] | [41.0, 40.0] | [233, 122] |
p03317 | u149260203 | 2,000 | 1,048,576 | 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. | ["import math\nN,K = [int(i) for i in input().split()]\na = list(input().split())\nm = a.index('1')\nif m == 0 or m == N-1:\n print(math.ceil((N-1)/(K-1)))\nelse:\n res = (K - m%K)%K\n print(math.ceil((m)/(K-1)) + math.ceil((N-m-1-res)/(K-1)))", "import math\nN,K = [int(i) for i in input().split()]\na = list(input().split())\nm = a.index('1')\nif m == 0 or m == N-1:\n print(math.ceil((N-1)/(K-1)))\nelse:\n res = ((K-1) - m%(K-1))%(K-1)\n print(math.ceil((m)/(K-1)) + math.ceil((N-m-1-res)/(K-1)))"] | ['Wrong Answer', 'Accepted'] | ['s551296057', 's969001168'] | [10740.0, 10740.0] | [27.0, 27.0] | [242, 254] |
p03317 | u151366507 | 2,000 | 1,048,576 | 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. | ['import math\n\nN, K = map(int, input().split())\nA = list(map(int, input().split() ))\nmath.ceil( (N-1)/(K-1) )', 'import math\n\nN, K = map(int, input().split())\nA = list(map(int, input().split() ))\nprint(math.ceil( (N-1)/(K-1) ))'] | ['Wrong Answer', 'Accepted'] | ['s236323438', 's879060164'] | [13812.0, 13812.0] | [45.0, 43.0] | [107, 114] |
p03317 | u159335277 | 2,000 | 1,048,576 | 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. | ['n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nminpos = 0\nfor i in range(0, n):\n if a[i] == 1: minpos = i\nprint((minpos + k - 2) / (k - 1) + (n - minpos - 1 + k - 2) / (k - 1))', 'n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nprint((n - 1 + k - 2) // (k - 1))\n'] | ['Wrong Answer', 'Accepted'] | ['s294153432', 's880220232'] | [14008.0, 13880.0] | [49.0, 40.0] | [206, 110] |
p03317 | u160244242 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input().split())\nlst = list(map(int, input().split()))\na = lst.index(1)\nprint(math.ceil(a/2) + math.ceil((n-a-1)/2))', 'import math\nn, k = map(int, input().split())\nlst = list(map(int, input().split()))\na = lst.index(1)\nprint(math.ceil((n - 1) / (k-1)))'] | ['Runtime Error', 'Accepted'] | ['s908621397', 's238794386'] | [14008.0, 13812.0] | [41.0, 42.0] | [132, 133] |
p03317 | u161537170 | 2,000 | 1,048,576 | 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. | ["import math\n\ndef calc_manipulate_times(Klen,len):\n if len == 0:\n return 0\n elif Klen>=len:\n return 1\n else:\n return math.ceil((len - Klen)/(Klen-1)) + 1\n\nN,K = map(int,input('').split())\nA = list(input().split(' '))\n\nleft_count = A.index('1')+1\nright_count = len(A)-A.index('1')\n# print(A)\nprint(left_count)\nprint(right_count)\n\n#\n\n\nprint(calc_manipulate_times(K,left_count) )\nprint(calc_manipulate_times(K,right_count))\n\nans = calc_manipulate_times(K,left_count) + calc_manipulate_times(K,right_count)\nprint(ans)\n", "import math\n\nN,K = map(int,input('').split())\nA = list(input().split(' '))\n\ncount = A.index('1') + len(A)-A.index('1')-1\nprint(math.ceil(count/(K-1)))\n"] | ['Wrong Answer', 'Accepted'] | ['s889052249', 's719437345'] | [10740.0, 10740.0] | [28.0, 28.0] | [628, 151] |
p03317 | u166306121 | 2,000 | 1,048,576 | 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. | ['N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\n\n# if A[i] == 1:\n# return i\n# n = search(A)\n#\n\nprint((N-1) // (K-1))', 'N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\n\n# if A[i] == 1:\n# return i\n# n = search(A)\n#\n\nprint(-((-N+1) // (K-1)))'] | ['Wrong Answer', 'Accepted'] | ['s830091308', 's290484207'] | [13812.0, 13880.0] | [41.0, 42.0] | [237, 241] |
p03317 | u166696759 | 2,000 | 1,048,576 | 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. | ['8 3\n7 3 1 8 4 6 2 5', 'N, K = map(int,input().split())\nA = list(map(int, input().split()))\nif (N-1) % (K-1) == 0:\n\tprint((N-1)//(K-1))\nelse:\n \tprint((N-1)//(K-1)+1)'] | ['Runtime Error', 'Accepted'] | ['s582129553', 's790005143'] | [2940.0, 14008.0] | [17.0, 40.0] | [19, 142] |
p03317 | u167647458 | 2,000 | 1,048,576 | 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. | ["import math\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n print(math.ceil((n -1) // (k - 1)))\n\n \nif __name__ == '__main__':\n main()", "import math\n\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n print(math.ceil((n -1) / (k - 1)))\n\n \nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s014141334', 's562537443'] | [13812.0, 13812.0] | [40.0, 40.0] | [186, 185] |
p03317 | u171328579 | 2,000 | 1,048,576 | 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. | ['N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nN -= 1\nK -= 1\nprint(N // K)\n', 'import math\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nN -= K\nK -= 1\nC = math.ceil(N/K)\n\nprint(C+1)\n'] | ['Wrong Answer', 'Accepted'] | ['s548836626', 's717118235'] | [20468.0, 20456.0] | [52.0, 49.0] | [95, 125] |
p03317 | u173329233 | 2,000 | 1,048,576 | 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. | ['from math import floor\nnk = input()\nn, k = nk.split()\nn = int(n)\nk = int(k)\n\nan = input()\nan_list = an.split()\nmin = min(an_list)\n\nmin_ind = an_list.index(min) + 1\nafter = (n - min_ind) / (k-1)\nbefore = (min_ind - 1) / (k-1)\n\nres = floor((n-1)/(k-1))\n\n\nprint(int(res))\n', 'from math import floor\nnk = input()\nn, k = nk.split()\nn = int(n)\nk = int(k)\n\nan = input()\nan_list = an.split()\nmin = min(an_list)\n\nmin_ind = an_list.index(min) + 1\nafter = (n - min_ind) / (k-1)\nbefore = (min_ind - 1) / (k-1)\n\nres = 0\n\nif min_ind < k or (n - min_ind) > (k-1):\n res = floor(n/(k-1)) \n\nelse:\n if after.is_integer():\n res = res + after\n else:\n res = res + floor(after) + 1\n\n if before.is_integer():\n res = res + before\n else:\n res = res + floor(before) + 1\n\n\nprint(int(res))', 'from math import floor\nnk = input()\nn, k = nk.split()\nn = int(n)\nk = int(k)\n\nan = input()\nan_list = an.split()\nmin = min(an_list)\n\nmin_ind = an_list.index(min) + 1\nafter = (n - min_ind) / (k-1)\nbefore = (min_ind - 1) / (k-1)\n\nres = 0\n\n\n\nif min_ind < k or (n - min_ind) > (k-1):\n res = floor(n/(k-1))\n\n\n\nelse:\n if after.is_integer():\n res = res + after\n else:\n res = res + floor(after) + 1\n\n if before.is_integer():\n res = res + before\n else:\n res = res + floor(before) + 1\n\n\nprint((n-1)/(k-1))', 'from math import floor\nnk = input()\nn, k = nk.split()\nn = int(n)\nk = int(k)\n\nan = input()\nan_list = an.split()\nmin = min(an_list)\n\nmin_ind = an_list.index(min) + 1\nafter = (n - min_ind) / (k-1)\nbefore = (min_ind - 1) / (k-1)\n\n\n\nif (n-1)%(k-1):\n res = (n-1)/(k-1)\nelse:\n res = (n-1)//(k-1) + 1\n\nprint(res)\n', '\nnk = input()\nn, k = nk.split()\nn = int(n)\nk = int(k)\n\nan = input()\nan_list = an.split()\nmin = min(an_list)\n\n\n\n\n\nif (n-1)%(k-1)==0:\n res = (n-1)//(k-1)\nelse:\n res = (n-1)//(k-1) + 1\n\nprint(res)\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s201360470', 's319951557', 's526360893', 's990685692', 's654372329'] | [10420.0, 3060.0, 10548.0, 10420.0, 10420.0] | [28.0, 17.0, 29.0, 29.0, 28.0] | [269, 514, 536, 311, 200] |
p03317 | u175034939 | 2,000 | 1,048,576 | 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. | ['n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nif n == k:\n print(1)\n exit()\n\nl = 0\nr = 0\none = False\nfor i in range(n):\n if a[i] == 1:\n one = True\n continue\n if one == False:\n l += 1\n else:\n r += 1\n\nif k >= min(l+1,r+1):\n n -= k\n if n%(k-1) == 0:\n n //= k-1\n else:\n n //= k-1\n n += 1\n pritn(n+1)\nelse:\n if l % (k-1) == 0:\n l //= k-1\n else:\n l //= k-1\n l += 1\n \n if r % (k-1) == 0:\n r //= k-1\n else:\n r //= k-1\n r += 1\n print(l+r)', 'import math\n\nn,k = map(int,input().split())\na = list(map(int,input().split()))\n\nn -= k\nprint(math.ceil(n/(k-1)) + 1)\n'] | ['Runtime Error', 'Accepted'] | ['s350779731', 's328768601'] | [14008.0, 13812.0] | [59.0, 39.0] | [589, 117] |
p03317 | u175426149 | 2,000 | 1,048,576 | 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. | ['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nprint(N, K, len(A))\n\nindex = A.index(1)\nprint(index)\n\nbefore_num = index\nafter_num = N - index - 1\n\nope = 0\nif N == K:\n ope = 1\nelif K > before_num or K > after_num:\n div, mod = divmod(N, K - 1)\n if mod == 0:\n ope = div\n else:\n ope = div + 1\nelif K % 2:\n before_num -= (K - 1) // 2\n after_num -= (K - 1) // 2\n ope += before_num // (K - 1)\n ope += after_num // (K - 1)\nelse:\n ope1 = 0\n ope2 = 0\n before_num = index - (K - 2) // 2\n after_num = N - index - 1 - K // 2\n div, mod = divmod(before_num, K - 1)\n if mod == 0:\n ope1 += div\n else:\n ope1 += div + 1\n div, mod = divmod(after_num, K - 1)\n if mod == 0:\n ope1 += div\n else:\n ope1 += div + 1\n before_num = index - K // 2\n after_num = N - index - 1 - (K - 2) // 2\n div, mod = divmod(before_num, K - 1)\n if mod == 0:\n ope2 += div\n else:\n ope2 += div + 1\n div, mod = divmod(after_num, K - 1)\n if mod == 0:\n ope2 += div\n else:\n ope2 += div + 1\n print(ope1, ope2)\n if ope1 < ope2:\n ope = ope1\n else:\n ope = ope2\n ope += 1\n\nprint(ope)\n\n', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nindex = A.index(1)\nprint(index)\n\nbefore_num = index\nafter_num = N - index - 1\n\nope = 0\nif N == K:\n ope = 1\nelif K > before_num or K > after_num:\n div, mod = divmod(N, K - 1)\n if mod == 0:\n ope = div\n else:\n ope = div + 1\nelif K % 2:\n before_num -= (K - 1) // 2\n after_num -= (K - 1) // 2\n ope += before_num // (K - 1)\n ope += after_num // (K - 1)\nelse:\n ope1 = 0\n ope2 = 0\n before_num = index - (K - 2) // 2\n after_num = N - index - 1 - K // 2\n div, mod = divmod(before_num, K - 1)\n if mod == 0:\n ope1 += div\n else:\n ope1 += div + 1\n div, mod = divmod(after_num, K - 1)\n if mod == 0:\n ope1 += div\n else:\n ope1 += div + 1\n before_num = index - K // 2\n after_num = N - index - 1 - (K - 2) // 2\n div, mod = divmod(before_num, K - 1)\n if mod == 0:\n ope2 += div\n else:\n ope2 += div + 1\n div, mod = divmod(after_num, K - 1)\n if mod == 0:\n ope2 += div\n else:\n ope2 += div + 1\n print(ope1, ope2)\n if ope1 < ope2:\n ope = ope1\n else:\n ope = ope2\n ope += 1\n\nprint(ope)\n\n', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndiv, mod = divmod(N - 1, K - 1)\nif mod == 0:\n print(div)\nelse:\n print(div + 1)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s231102110', 's692612788', 's443746595'] | [13812.0, 13812.0, 13812.0] | [42.0, 41.0, 42.0] | [1232, 1211, 155] |
p03317 | u175590965 | 2,000 | 1,048,576 | 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. | ['n,k = list(map(int,input().split()))\na = lsit(map(int,input().split()))\nprint((n-1+k-2)//(k-1))', 'n,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nprint((n-1+k-2)//(k-1))'] | ['Runtime Error', 'Accepted'] | ['s684448402', 's122474345'] | [3060.0, 14008.0] | [17.0, 40.0] | [95, 95] |
p03317 | u177040005 | 2,000 | 1,048,576 | 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. | ['N,K = map(int, input().split())\nA = list(map(int, input().split()))\n\ni = A.index(1)\nans1 = ans2 = ans3 = 1000010\nif N<=K:\n print(1)\n exit()\nif len(A[:i]) < K-1:\n ans1 = -(-len(A[:i])//(K-1)) + -(-(len(A[i+1:]) - (K-len(A[:i])))//(K-1))\nif len(A[i+1:]) < K-1:\n ans2 = -(-(len(A[:i]) - (K-len(A[i+1:])))//(K-1)) + -(-len(A[i+1:]))//(K-1)\nif len(A[:i]) >= K-1 and len(A[i+1:]) >= K-1:\n ans3 = -(-len(A[:i])//(K-1)) + -(-len(A[i+1:])//(K-1))\n\nans = min(ans1,ans2,ans3)\nprint(ans)\n', 'N,K = map(int, input().split())\nprint(1 + -( -(N-K)//(K-1) ) )\n'] | ['Wrong Answer', 'Accepted'] | ['s658980830', 's012404967'] | [14324.0, 2940.0] | [42.0, 17.0] | [491, 63] |
p03317 | u179169725 | 2,000 | 1,048,576 | 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. | ['\n\n\nimport sys\nread = sys.stdin.readline\nra = range\nenu = enumerate\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\nN, K = read_ints()\nif N == K:\n print(1)\n exit()\nA = read_ints()\nK -= 1\ni = A.index(1)\n\n# if i < K and i >= (N - K):\n# print(2)\n# exit()\n\n\n\n\nright = (i - 1) // K + 1\nleft = (N - 1 - i) // K\n\n\n\n\nprint(right + left)\n', '\n\n\nimport sys\nread = sys.stdin.readline\nra = range\nenu = enumerate\n\n\ndef read_ints():\n return list(map(int, read().split()))\n\n\nN, K = read_ints()\nif N == K:\n print(1)\n exit()\nA = read_ints()\n\nK -= 1\ni = A.index(1)\n\n\nans = 0\nfor j in range(0, N - 1, K):\n ans += 1\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s934474070', 's705039586'] | [13304.0, 13876.0] | [42.0, 44.0] | [601, 358] |
p03317 | u194856115 | 2,000 | 1,048,576 | 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. | ['from math import ceil\nN, K = map(int, raw_input().split())\nA = map(int, raw_input().split())\n\nprint (int(ceil((N-1)/(K-1))))\n', 'from math import ceil\nN, K = map(int, raw_input().split())\nA = map(int, raw_input().split())\n\nprint (ceil((N-1)//(K-1)))\n', 'from math import ceil\nN, K = map(int, raw_input().split())\nA = map(int, raw_input().split())\n\nprint (ceil((N-1)/(K-1)))\n', 'from math import ceil\nN, K = map(int, raw_input().split())\nA = map(int, raw_input().split())\n\nprint (ceil(N - 1 // K - 1))', 'import math\nN, K = map(int, input().split())\ninput()\n \nprint(math.ceil((N-1)/(K-1)))\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s125451968', 's183538251', 's411835757', 's736613656', 's812294045'] | [2940.0, 2940.0, 2940.0, 2940.0, 4724.0] | [17.0, 17.0, 17.0, 17.0, 18.0] | [125, 121, 120, 122, 89] |
p03317 | u198905553 | 2,000 | 1,048,576 | 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. | ['n,k = map(int,input().split())\na = list(map(int,input().split()))\nprint((n-1) // (k-1))', 'import math\nn,k = map(int,input().split())\na = list(map(int,input().split()))\nprint(math.ceil((n-1) / (k-1)))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s423088198', 's293537294'] | [13880.0, 13812.0] | [39.0, 40.0] | [87, 179] |
p03317 | u208479266 | 2,000 | 1,048,576 | 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. | ['n, c = map(int, input().split())\nimport math\nprint(math.ceil((n-1)//(c-1)))\n', 'import math\nn, c = map(int, input().split())\n\na = input()\nprint(math.ceil((n-1)//(c-1)))\n', 'n, c = map(int, input().split())\nprint((n-1)//(c-1))\n', 'import math\nN,K = map(int,input().split())\nprint(math.ceil((N-1)/(K-1)))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s186323749', 's657435822', 's697225310', 's465879361'] | [3060.0, 4724.0, 2940.0, 3060.0] | [17.0, 19.0, 18.0, 17.0] | [76, 89, 53, 72] |
p03317 | u217975120 | 2,000 | 1,048,576 | 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. | ['import math\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nlena = len(a)\nindex = a.index(1) + 1\nlenb = lena - index\nif lena / 2 > index:\n front = math.ceil((index-1) / (k-1))\n if k == n :opt = 0\n elif k - index > 0 :opt = k - index\n else :opt = 0\n back = math.ceil((lenb - opt) / (k-1))\n\nelse:\n back = math.ceil((lenb-1) / (k-1))\n if k - lenb > 0 :opt = k - lenb\n else :opt = 0\n front = math.ceil((index - opt) % (k-1))\n\nans = front + back\nprint(ans)\n', 'import math\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nprint(math.ceil((n-1) / (k-1)))\n'] | ['Wrong Answer', 'Accepted'] | ['s037760579', 's967243778'] | [13812.0, 13812.0] | [40.0, 39.0] | [503, 114] |
p03317 | u225642513 | 2,000 | 1,048,576 | 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. | ['N,K = map(int, input().split())\ninput()\njudge = (N-1)%(K-1) == 0\nif judge:\n print(int((N-1)/(K-1))\nelse:\n print(int((N-1)//(K-1)+1)\n', 'N,K = map(int, input().split())\ninput()\njudge = (N-1)%(K-1) == 0\nif judge:\n print(int((N-1)/(K-1)))\nelse:\n print(int((N-1)//(K-1)+1))\n'] | ['Runtime Error', 'Accepted'] | ['s591555438', 's609478327'] | [2940.0, 4724.0] | [17.0, 21.0] | [138, 140] |
p03317 | u227082700 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na=input().split()\nm=a.index("1")\na,b=m,n-m-1\nans=((a+1)//(k-1))+1\nb-=a%(k-1)\nans+=((b+1)//(k-1))+1\nprint(ans)', 'n,k=map(int,input().split());print(((n+2)//(k-1))+1)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nprint(((n-2)//(k-1))+1)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s006571402', 's058386374', 's221365188'] | [10420.0, 3060.0, 14004.0] | [26.0, 17.0, 40.0] | [138, 52, 85] |
p03317 | u228636605 | 2,000 | 1,048,576 | 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. | ['N , K = (int(i) for i in input().split())\nA = list(int(i) for i in range(input().split(),N))\n\ncount = 1\ns = K\n\nwhile s < N:\n s = s + (K - 1)\n count = count + 1\n print(s)\nprint(count)\n', 'N , K = (int(i) for i in input().split())\nA = list(int(i) for i in input().split())\n\ncount = 1\ns = K\n\nwhile s < N:\n s = s + (K - 1)\n count = count + 1\n print(s)\nprint(count)\n', 'N , K = (int(i) for i in input().split())\nA = list(int(i) for i in input().split())\n \ncount = 1\ns = K\n \nwhile s < N:\n s = s + (K - 1)\n count = count + 1\n #print(s)\nprint(count)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s635361556', 's715664560', 's473010613'] | [10548.0, 14008.0, 14008.0] | [25.0, 93.0, 54.0] | [193, 184, 186] |
p03317 | u239342230 | 2,000 | 1,048,576 | 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. | ['N,K=map(int,input().split())\nA=list(map(int,input().split()))', 'N,K=map(int,input().split())\nA=list(map(int,input().split()))\nprint((N-2)//(K-1)+1)'] | ['Wrong Answer', 'Accepted'] | ['s793271241', 's559604181'] | [13880.0, 13880.0] | [39.0, 42.0] | [61, 83] |
p03317 | u247830763 | 2,000 | 1,048,576 | 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. | ['import math\nn,k = map(int,input().split())\nls = list(map(int,input().split()))\na = min(ls)\ni = ls.index(a)\nl = i\nr = n - i - 1\nif r < l:\n l,r = r,l\nprint(l,r)\nif n == k:\n print("1")\nelif l < k-1:\n print(int(math.ceil((r-k+1+l)/(k-1)))+1)\nelse:\n print(int(math.ceil(l/(k-1))+math.ceil(r/(k-1))))\n', 'import math\nn,k = map(int,input().split())\nls = list(map(int,input().split()))\nprint(math.ceil((n-1)/(k-1)))\n'] | ['Wrong Answer', 'Accepted'] | ['s949248190', 's211570512'] | [13812.0, 13812.0] | [43.0, 41.0] | [307, 109] |
p03317 | u248670337 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\nA=list(map(int,input().split()))\nr=n-A.index(1)-1\nl=A.index(1)\nprint(r//(k-1)+l//(k-1) if n>k else 1)', 'n,k=map(int,input().split())\nA=list(map(int,input().split()))\nr=n-A.index(1)-1\nl=A.index(1)\nprint(min(-(-r//(k-1))-(-l//(k-1)),-(-(n-1)//(k-1))))'] | ['Wrong Answer', 'Accepted'] | ['s627952824', 's698206975'] | [14008.0, 14008.0] | [42.0, 44.0] | [130, 145] |
p03317 | u261891508 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na=list(map(int,input().split()))\nichi=a.index(1) \n\nans=float("inf")\n\n\nimport math\nfor i in range(k):\n left=math.ceil((ichi-i)/(k-1)) \n right=math.ceil((n-ichi-(k-i))/(k-1)) \n print(ichi-i,left,right)\n ans=min(ans,1+left+right)\nprint(ans)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nichi=a.index(1) \n\nans=float("inf")\n\n\nimport math\nfor i in range(k):\n if ichi-i<0 or ichi+k-i>n:\n break\n left=math.ceil((ichi-i)/(k-1)) \n right=math.ceil((n-ichi-(k-i))/(k-1)) \n \n ans=min(ans,1+left+right)\nprint(ans)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nichi=a.index(1) \n\nans=float("inf")\n\n\nimport math\nfor i in range(k):\n if ichi-i<0 or ichi+k-i>n-1:\n break\n left=math.ceil((ichi-i)/(k-1)) \n right=math.ceil((n-ichi-(k-i))/(k-1)) \n \n ans=min(ans,1+left+right)\nprint(ans)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nichi=a.index(1) \n\nans=float("inf")\n\n\nimport math\nfor i in range(k):\n if ichi-i<0 or ichi+k-i>n: \n \n continue\n left=math.ceil((ichi-i)/(k-1)) \n right=math.ceil((n-ichi-(k-i))/(k-1)) \n \n ans=min(ans,1+left+right)\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s415764770', 's794001896', 's980682445', 's471268914'] | [13880.0, 13880.0, 13880.0, 14004.0] | [290.0, 41.0, 40.0, 76.0] | [520, 561, 563, 655] |
p03317 | u264998565 | 2,000 | 1,048,576 | 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. | ['# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport sys\n\nN, K = map(int, input().split())\nA = np.array(list(map(int, input().split())), dtype=np.int)\n\narg = 0\nop_l = 0\nwhile(True):\n arg_new = arg + K - 1\n op_l += 1\n if np.any(A[arg:arg_new+1] == 1):\n last_arg = (arg, arg_new)\n break\n arg = arg_new\n\nif arg_new == N-1:\n print(op_l)\n sys.exit()\n\narg = N-1\nop_r = 0\nwhile(True):\n arg_new = arg - K + 1\n op_r += 1\n if np.any(A[arg_new:arg+1] == 1):\n if (arg_new, arg) == last_arg:\n op_r -= 1\n break\n if arg_new == last_arg[1]+1:\n break\n arg = arg_new\n\nprint(op_l+op_r)', '# -*- coding: utf-8 -*-\n\nimport math\n\nN, K = map(int, input().split())\nA = np.array(list(map(int, input().split())), dtype=np.int)\n\nprint(math.ceil(N-1//K-1))', '# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport sys\n\nN, K = map(int, input().split())\nA = np.array(list(map(int, input().split())), dtype=np.int)\n\narg = 0\nop_l = 0\nwhile(True):\n arg_new = arg + K - 1\n op_l += 1\n if np.any(A[arg:arg_new+1] == 1):\n break\n arg = arg_new\n\nif arg_new == N-1:\n print(op_l)\n sys.exit()\n\narg = N-1\nop_r = 0\nwhile(True):\n arg_new = arg - K + 1\n op_r += 1\n if np.any(A[arg_new:arg+1] == 1):\n break\n arg = arg_new\n\nprint(op_l+op_r)', '# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport sys\n\nN, K = map(int, input().split())\nA = np.array(list(map(int, input().split())), dtype=np.int)\n\narg = 0\nop_l = 0\nwhile(True):\n arg_new = arg + K - 1\n op_l += 1\n if np.any(A[arg:arg_new+1] == 1):\n last_arg = (arg, arg_new)\n break\n arg = arg_new\n\nif arg_new == N-1:\n print(op_l)\n sys.exit()\n\narg = N-1\nop_r = 0\nwhile(True):\n arg_new = arg - K + 1\n op_r += 1\n if np.any(A[arg_new:arg+1] == 1):\n if (arg_new, arg) == last_arg:\n op_r -= 1\n break\n if arg_new = last_arg[1]+1:\n break\n arg = arg_new\n\nprint(op_l+op_r)', '# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport itertools\n\nN, K = map(int, input().split())\nA = np.array(list(map(int, input().split())), dtype=np.int)\n\nfirst_index = np.arange(0, N-K+1)\n\nperm = list(itertools.permutations(first_index))\n\nstep_min = len(first_index)\n\nfor indexs in perm:\n Ac = A.copy()\n step = 0\n for i in indexs:\n Ac[i:i+K] = Ac[i:i+K].min()\n step += 1\n if np.all(Ac == 1) and step < step_min:\n step_min = step\n break\n if step > step_min:\n break\n \nprint(step_min)', '# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport sys\n\nN, K = map(int, input().split())\nA = np.array(list(map(int, input().split())), dtype=np.int)\n\narg = 0\nop_l = 0\nwhile(True):\n arg_new = arg + K - 1\n op_l += 1\n if np.any(A[arg:arg_new+1] == 1):\n last_arg = (arg, arg_new)\n break\n arg = arg_new\n\nif arg_new == N-1:\n print(op_l)\n sys.exit()\n\narg = N-1\nop_r = 0\nwhile(True):\n arg_new = arg - K + 1\n op_r += 1\n if np.any(A[arg_new:arg+1] == 1):\n if (arg_new, arg) == last_arg:\n op_r -= 1\n break\n arg = arg_new\n\nprint(op_l+op_r)', '# -*- coding: utf-8 -*-\n\nimport math\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nprint(math.ceil((N-1)/(K-1)))\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Accepted'] | ['s135584888', 's255538704', 's397748611', 's441193196', 's751468615', 's924773605', 's836356978'] | [23368.0, 3060.0, 23368.0, 3064.0, 1498672.0, 23396.0, 13812.0] | [929.0, 17.0, 892.0, 17.0, 2200.0, 918.0, 40.0] | [643, 158, 501, 642, 568, 596, 138] |
p03317 | u265281278 | 2,000 | 1,048,576 | 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. | ['N,K=map(int, input().split())\nA=input()\nif (N-1)%(K-1):\n print((N-1)//(K-1))\nelse:\n print((N-1)//(K-1)+1)', 'N,K=map(int, input().split())\nA=input()\nif (N-1)%(K-1):\n print((N-1)//(K-1)+1)\nelse:\n print((N-1)//(K-1))'] | ['Wrong Answer', 'Accepted'] | ['s841799729', 's920244066'] | [4724.0, 4724.0] | [19.0, 18.0] | [111, 111] |
p03317 | u278832126 | 2,000 | 1,048,576 | 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. | ['from math import ceil\nN, K = map(int, input().split)\nnums = list(map(int, input().split))\nindex = nums.index(1)\nprint(ceil(index / (K - 1)) + ceil((N - index - 1) / (K - 1)))', 'import math\nN, K = map(int, input().split())\nnums = input()\nprint(math.ceil((N - 1) / (K - 1)))'] | ['Runtime Error', 'Accepted'] | ['s555639118', 's860866127'] | [3060.0, 4724.0] | [17.0, 21.0] | [174, 95] |
p03317 | u284854859 | 2,000 | 1,048,576 | 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. | ['# your code goes here\n\nN,K = map(int,input().split())\nli = list(map(int,input().split()))\t\nif N == K:\n\tprint(1)\n\tquit()\ni = 1\nN = N-K\n\nwhile N >= K:\n\tN = N - K +1\n\ti = i + 1\n\nprint()', 'import sys\ninput = sys.stdin.readline\n\nn,k = map(int,input().split())\na = list(map(int,input().split()))\n\nres = 1\ncnt = k\n\nif n <= cnt:\n print(res)\nelse:\n if (n-k)%(k-1) == 0:\n print(1 + (n-k)//(k-1))\n else:\n print(1 + (n-k)//(k-1)+1)'] | ['Wrong Answer', 'Accepted'] | ['s964082276', 's447773439'] | [14008.0, 14388.0] | [48.0, 42.0] | [182, 257] |
p03317 | u288087195 | 2,000 | 1,048,576 | 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. | ['import math\nN, K = [int(t) for t in input().split()]\nA = [int(t) for t in input().split()]\n\nidx = A.index(1)\nleft = A[:idx+1]\nright = A[idx:]\n\n\ndef get_cnt(L):\n return math.ceil((len(L) - 1) / (K-1))\n\n\nif left + 1 < K or N - right < K:\n print(get_cnt(A))\nelse:\n print(get_cnt(left) + get_cnt(right))\n', 'import math\nN, K = [int(t) for t in input().split()]\nA = [int(t) for t in input().split()]\n\nidx = A.index(1)\nleft = A[:idx+1]\nright = A[idx:]\n\nprint(idx)\nprint(left)\nprint(right)\n\n\ndef get_cnt(L):\n return math.ceil((len(L) - 1) / (K-1))\n\n\nif idx + 1 < K or N - idx < K:\n print(get_cnt(A))\nelse:\n print(get_cnt(left) + get_cnt(right))\n', 'import math\nN, K = [int(t) for t in input().split()]\nA = [int(t) for t in input().split()]\n\nprint(math.ceil((N - 1) / (K-1)))\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s011429247', 's507125821', 's637896322'] | [13812.0, 13812.0, 13812.0] | [48.0, 54.0, 44.0] | [309, 343, 126] |
p03317 | u299869545 | 2,000 | 1,048,576 | 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. | ['n, k =map(int, input().split())\nprint( (n-1) / (k-1) + ((n-1)%(k-1) != 0))', 'n, k =map(int, input().split())\nprint( (n-1) // (k-1) + ((n-1)%(k-1) != 0))'] | ['Wrong Answer', 'Accepted'] | ['s667634806', 's842137066'] | [2940.0, 3060.0] | [17.0, 17.0] | [74, 75] |
p03317 | u303059352 | 2,000 | 1,048,576 | 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. | ['print((int(input()) - 2) / (int(input()) - 1) + 1)', '[print((n[0] - 2) / (n[1] - 1) + 1) for n in [list(map(int, input().split()))]]', '[print(int((n[0] - 2) / (n[1] - 1) + 1)) for n in [list(map(int, input().split()))]]'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s926445314', 's973598532', 's574069199'] | [2940.0, 3060.0, 3060.0] | [18.0, 18.0, 20.0] | [50, 79, 84] |
p03317 | u305781333 | 2,000 | 1,048,576 | 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. | ['N, K = [int(i) for i in input().split()]\nA = [int(i) for i in input().split()]\nmin_number = min(A)\nleft = A.index(min_number)\nright = A.index(min_number)\ncount = 0\n\nwhile len(list(set(A))) > 1:\n if left > 0:\n next_left = left-K+1 if left-K+1 >= 0 else 0\n A[next_left:left+1] = [min_number]*len(A[next_left:left+1])\n left = left-K+1\n count+=1\n print(A)\n \n if right < len(A)-1:\n next_right = right+K-1 if right+K-1 <= len(A)-1 else len(A)-1\n A[right:next_right+1] = [min_number]*len(A[right:next_right+1])\n right = right+K-1\n count+=1\n print(A)\n\nprint(count)', 'import math\n\nN, K = [int(i) for i in input().split()]\nA = [int(i) for i in input().split()]\nprint(math.ceil((N-1)/(K-1)))'] | ['Wrong Answer', 'Accepted'] | ['s304255470', 's858729759'] | [146024.0, 13812.0] | [2039.0, 44.0] | [590, 121] |
p03317 | u305965165 | 2,000 | 1,048,576 | 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. | ['import math\nn, k = (int(i) for i in input().split()) \na = [int(i) for i in input().split()]\n\nprint( 1 + math.ceil((n-k) // (k-1)) )', 'n, k = (int(i) for i in input().split()) \na = [int(i) for i in input().split()]\n\nprint(n // k)', 'import math\nn, k = (int(i) for i in input().split()) \na = [int(i) for i in input().split()]\n\nprint( 1 + math.ceil((n-k) / (k-1)) )'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s623904333', 's768248305', 's382467576'] | [13812.0, 13880.0, 13812.0] | [44.0, 46.0, 46.0] | [132, 95, 131] |
p03317 | u315485238 | 2,000 | 1,048,576 | 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. | ['import math\nN, K = list(map(int, input().split()))\nA = list(map(int, input().split())) \n\nm = min(A)\nanswer = N\n\nfor i in range(N-K+1): \n if not k in A[i:i+K]:\n continue\n answer = min(answer,\n (1 + math.ceil(i/(K-1)) + math.ceil((N-K-i)/(K-1))))\nprint(answer)', 'N, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nprint((N-1)//(K-1) + bool((N-1)%(K-1)))'] | ['Runtime Error', 'Accepted'] | ['s769278567', 's059665829'] | [13812.0, 13812.0] | [44.0, 41.0] | [310, 115] |
p03317 | u325227960 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\nA=list(map(int,input().split()))\n\nm=A.index(1)\n\nle=m\nri=n-m\nif le//(k-1)!=0 :\n ri-=(k-1)-le%(k-1)\n\nprint(le//(k-1)+ri//(k-1))\n', 'n,k=map(int,input().split())\nA=list(map(int,input().split()))\n\n#m=A.index(1)\n\n#le=m\n#ri=n-m\n#if le//(k-1)!=0 :\n# ri-=(k-1)-le%(k-1)\n\n#print(le//(k-1)+ri//(k-1))\n\nprint(int((n-1-0.1)//(k-1)+1))\n'] | ['Wrong Answer', 'Accepted'] | ['s653661049', 's415182983'] | [14008.0, 13812.0] | [41.0, 40.0] | [158, 196] |
p03317 | u328364772 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input().split())\nA = input()\nans = (n-1)//(k-1)\nprint(ans if (n-1) % (k-1) == ', 'n, k = map(int, input().split())\nA = input()\nans = (n-1)//(k-1)\nprint(ans if (n-1) % (k-1) == 0 else ans + 1)\n'] | ['Runtime Error', 'Accepted'] | ['s740520237', 's159880099'] | [2940.0, 4724.0] | [17.0, 20.0] | [94, 110] |
p03317 | u331381193 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input().split())\nx = [map(int, input().split())]\n\nfor i in range(n):\n\tl=k*i-(i-1)\n\tif i==0:\n\t\tl=k\n\tif l>=n:\n\t\tprint(i+1)\n\t\tbreak', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nfor i in range(1,n+1):\n\tl=k*i-(i-1)\n\tif l>=n:\n\t\tprint(i)\n\t\tbreak'] | ['Wrong Answer', 'Accepted'] | ['s216748265', 's102374267'] | [10420.0, 13880.0] | [39.0, 50.0] | [144, 134] |
p03317 | u342563578 | 2,000 | 1,048,576 | 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. | ['N, K = map(int,input().split())\nAlist = list(map(int,input().split()))\nprint(-(-N-1//K-1))', 'N, K = map(int,input().split())\nAlist = list(map(int,input().split()))\nprint(-(-N-1//k-1))', 'N, K = map(int,input().split())\nAlist = list(map(int,input().split()))\nn = 0\nl = 0\nr = o\nfor i in range(N):\n if Alist[i] == 1:\n p = i\nn = n -(-p//(K-1))\nn = n -(-(N-p-1)//(K-1))\nprint(-(-N-1//k-1))', 'N, K = map(int,input().split())\nAlist = list(map(int,input().split()))\nprint(-(-(N-1)//(K-1)))'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s044442496', 's229787875', 's356622960', 's238868232'] | [13880.0, 13880.0, 13880.0, 14004.0] | [41.0, 41.0, 40.0, 40.0] | [90, 90, 207, 94] |
p03317 | u347640436 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input())\nprint(((n - 1) + (k - 2)) // (k - 1))\n', 'n, k = map(int, input().split())\nprint(((n - 1) + (k - 2)) // (k - 1))\n'] | ['Runtime Error', 'Accepted'] | ['s270349250', 's626728912'] | [2940.0, 2940.0] | [17.0, 17.0] | [63, 71] |
p03317 | u366644013 | 2,000 | 1,048,576 | 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. | ['import math\nn, k = map(int, input().split())\na = input()\nprint(math.celi(n-1/k-1))', 'import math\nn, k = map(int, input().split())\na = input()\nprint(math.ceil((n-1)/(k-1)))'] | ['Runtime Error', 'Accepted'] | ['s875872848', 's888026555'] | [4724.0, 4724.0] | [18.0, 18.0] | [82, 86] |
p03317 | u366964431 | 2,000 | 1,048,576 | 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. | ["import numpy as np\n#import pdb\n\ntmp = list(map(int, input().strip().split(' ')))\nN = tmp[0]\nK = tmp[1]\nA = list(map(int, input().strip().split(' ')))\n\nA = np.asarray(A)\npos = np.argmin(A)\n\nleft = pos\nright = N - pos - 1\n\nst_list = [x for x in range(max(0, pos - K + 1), min(pos + 1, N))]\n\ncnt = np.inf\nfor st in st_list:\n ed = st + K - 1\n left = st\n right = N - ed - 1\n left_count = np.ceil(left / (K-1))\n right_count = np.ceil(right / (K-1))\n if cnt > (left_count + right_count):\n cnt = left_count + right_count\n\nprint(cnt)\n", "import numpy as np\n#import pdb\n\ntmp = list(map(int, input().strip().split(' ')))\nN = tmp[0]\nK = tmp[1]\nA = list(map(int, input().strip().split(' ')))\n\nA = np.asarray(A)\npos = np.argmin(A)\n\nleft = pos\nright = N - pos - 1\n\nst_list = [x for x in range(pos - K + 1, pos + 1)]\n\ncnt = np.inf\nfor st in st_list:\n ed = st + K - 1\n left = st\n right = N - ed - 1\n left_count = np.ceil(left / (K-1))\n right_count = np.ceil(right / (K-1))\n if cnt > (left_count + right_count):\n cnt = left_count + right_count\n\nprint(cnt)", "import numpy as np\n#import pdb\n\ntmp = list(map(int, input().strip().split(' ')))\nN = tmp[0]\nK = tmp[1]\nA = list(map(int, input().strip().split(' ')))\n\nA = np.asarray(A)\npos = np.argmin(A)\n\nleft = pos\nright = N - pos - 1\n\nst_list = [x for x in range(max(0, pos - K + 1), min(pos + 1, N))]\n\ncnt = np.inf\nfor st in st_list:\n ed = st + K - 1\n left = st\n right = N - ed - 1\n left_count = np.ceil(left / (K-1))\n right_count = np.ceil(right / (K-1))\n if cnt > (left_count + right_count):\n cnt = left_count + right_count\n\nprint(cnt.astype(np.uint64))", "import numpy as np\nimport math\n#import pdb\n\ntmp = list(map(int, input().strip().split(' ')))\nN = tmp[0]\nK = tmp[1]\nA = list(map(int, input().strip().split(' ')))\n\nN = N - K\ncnt = 1\ncnt += math.ceil(N / (K - 1))\nprint(cnt)\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s047147318', 's329327743', 's947191031', 's212281712'] | [25300.0, 23400.0, 24644.0, 23368.0] | [448.0, 597.0, 352.0, 174.0] | [550, 533, 567, 222] |
p03317 | u370661635 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na = list(map(int,input().split()))\n\nprint((n-1)//(k-1))', 'import math\nn,k=map(int,input().split())\nprint(math.ceil((n-k)/(k-1))+1)'] | ['Wrong Answer', 'Accepted'] | ['s176208762', 's123782105'] | [14008.0, 3064.0] | [40.0, 17.0] | [84, 72] |
p03317 | u375616706 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input().split())\na = (list)(map(int, input().split()))\n\n# print(-(-(n-1)//(k-1)))\nprint((n+1 + (k - 2)) // (k-1))\n', 'n, k = map(int, input().split())\na = (list)(map(int, input().split()))\n\nif n == k:\n print(1)\nelse:\n print(n//(k+1))\n', 'n, k = map(int, input().split())\na = (list)(map(int, input().split()))\n\nif n <= k:\n print(1)\nelse:\n print(n//k+1\n', 'n, k = map(int, input().split())\na = (list)(map(int, input().split()))\n\n# print(-(-(n-1)//(k-1)))\nprint((n - 1 + (k - 2)) // (k-1))\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s206703743', 's370253094', 's459099164', 's182111434'] | [13880.0, 13880.0, 2940.0, 13880.0] | [42.0, 42.0, 18.0, 44.0] | [130, 118, 115, 132] |
p03317 | u382639013 | 2,000 | 1,048,576 | 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. | ['N, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nimport math\nprint(ceil((N-1)/(K-1)))', 'N, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nimport math\nprint(math.ceil((N-1)/(K-1)))'] | ['Runtime Error', 'Accepted'] | ['s032680798', 's282537508'] | [20532.0, 20608.0] | [48.0, 50.0] | [112, 117] |
p03317 | u384679440 | 2,000 | 1,048,576 | 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. | ['import math\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nprint(math.ceil((N - 1) // (K - 1)))', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\nprint((N - 1) // (K - 1))', 'import math\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nprint(math.ceil((N - 1) / (K - 1)))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s478594201', 's554400483', 's770447544'] | [13812.0, 13880.0, 13812.0] | [40.0, 39.0, 40.0] | [117, 94, 116] |
p03317 | u395816772 | 2,000 | 1,048,576 | 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. | ['n,k = map(int,input().split())\na = [int(i) for i in input().split()]\n\nb = a.index(1) \nif b < k-1:\n b += k-1 -b\nif b > (n-1) -(k-1):\n b -= b - (k-1)\nc,d = divmod(b,k-1)\nans = c\nrem = d\nif d != 0:\n ans +=1\ne = n-1 -b\nc,d = divmod(e,k-1)\nans += c\nif d != 0:\n ans +=1\nif rem + d <= k-1 and rem != 0 or d != 0:\n ans -=1\nprint(ans)\n', 'n,k = map(int,input().split())\na = [int(i) for i in input().split()]\n\nb = a.index(1) \nif b < k-1:\n b += k-1 -b\nif b > (n-1) -(k-1):\n b -= b - (k-1)\nc,d = divmod(b,k-1)\nans = c\nrem = d\nif d != 0:\n ans +=1\ne = n-1 -b\nc,d = divmod(e,k-1)\nans += c\nif d != 0:\n ans +=1\nif rem + d <= k-1:\n ans -=1\nprint(ans)\n', 'n,k = map(int,input().split())\na = [int(i) for i in input().split()]\n\nb = a.index(1) \nans = 0\nb -= (k-1)\nif b < 0:\n b = a.index(1) + abs(b)\nif b > n-1 -(k-1):\n b -= b- (k-1)\nc,d = divmod(b,k-1)\nans += c\nif d != 0:\n ans +=1\ne,f = divmod(n-1 - b,k-1)\nans += e\nif f != 0:\n ans +=1\nif d != 0 and f != 0 and d + f <= k-1:\n ans -=1\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s441697018', 's494669389', 's488000003'] | [20580.0, 20404.0, 20504.0] | [49.0, 56.0, 55.0] | [341, 318, 351] |
p03317 | u404676457 | 2,000 | 1,048,576 | 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. | ['(n, k) = map(int, input().split())\n_ = input()\ncount = n // (k - 1)\nif n % k == 1:\n count -= 1\nprint(count)', '(n, k) = map(int, input().split())\n_ = input()\ncount = 0\n\nwhile n > k:\n n -= k - 1\n count += 1\n\ncount += 1\nprint(count)'] | ['Wrong Answer', 'Accepted'] | ['s152134287', 's090106587'] | [4280.0, 4724.0] | [18.0, 29.0] | [110, 125] |
p03317 | u405256066 | 2,000 | 1,048,576 | 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. | ['from sys import stdin\nN,K = [int(x) for x in stdin.readline().rstrip().split()]\ndata = [int(x) for x in stdin.readline().rstrip().split()]\nleft = data.index(1)\nright = N - data.index(1) - 1\nans = (left // (K-1)) + (right // (K-1)) + 2\nprint(ans)', 'from sys import stdin\nimport math\nN,K = [int(x) for x in stdin.readline().rstrip().split()]\nprint(math.ceil((N-1) / (K-1)))'] | ['Wrong Answer', 'Accepted'] | ['s744809893', 's281199062'] | [13880.0, 3060.0] | [46.0, 17.0] | [245, 123] |
p03317 | u408325839 | 2,000 | 1,048,576 | 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. | ['import math\nn, k = map(int,input().split())\ninput()\nprint((n-1)/(k-1), math.ceil((n - 1)/(k - 1)))\n', 'import math\nn, k = map(int,input().split())\ninput()\nprint(int(math.ceil((n - 1)//(k - 1))))\n', 'n, k = map(int,input().split())\nprint(n//(k-1) + 1)\n', 'import math\nn, k = map(int,input().split())\ninput()\nprint(math.ceil((n-1)/(k-1)))\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s191361649', 's400562988', 's845403902', 's916664363'] | [10148.0, 10168.0, 9160.0, 10156.0] | [28.0, 27.0, 44.0, 27.0] | [99, 92, 52, 82] |
p03317 | u411302151 | 2,000 | 1,048,576 | 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. | ['from math import ceil\n\nN, K = map(int, input().split())\nll = list(map(int, input().split()))\n\nidx = ll.index(1)\n\nl, r = idx, N-idx\nprint(l, r)\nprint(ceil((l)/(K-1))+ ceil((r-1)/(K-1)))', 'from math import ceil\n\nN, K = map(int, input().split())\nll = list(map(int, input().split()))\n\nprint(ceil((N-1) / (K-1)))'] | ['Wrong Answer', 'Accepted'] | ['s823333925', 's046408345'] | [13812.0, 13812.0] | [40.0, 41.0] | [184, 120] |
p03317 | u411858517 | 2,000 | 1,048,576 | 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. | ['N, K = map(int, input().split())\nA = list(map(int, input().split()))\nm = min(A)\nres = 0\nfor i in range(N):\n min_num = i\n if m == A[i]:\n break\n \n \nn1 = min_num \nn2 = N - min_num - 1\n\nif n1 == 0:\n res = math.ceil(n2/2)\nelif n2 == 0:\n res = math.ceil(n1/2)\nelse:\n res = math.ceil(n1/2) + math.ceil(n2/2)\n \nprint(res)', 'import math\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nm = min(A)\nres = 0\n\nmin_num = A.index(m)\n \nn1 = min_num \nn2 = N - min_num - 1\n\nif K < min(n1, n2):\n if n1 != n2:\n res = math.ceil(n1/(K-1)) + math.ceil(n2/(K-1))\n else:\n res = math.ceil((n1-1)/(K-1)) + math.ceil((n2-1)/(K-1)) + 1\nelse:\n res = math.ceil((max(n1, n2) - (K - min(n1, n2)))/(K-1)) + 1\n\nprint(res)', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nans = 1\ntmp = N - K\nans += tmp // (K - 1)\n\nif tmp%(K - 1) != 0:\n ans += 1\n\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s431346036', 's720518764', 's838425811'] | [13880.0, 13812.0, 13880.0] | [51.0, 43.0, 40.0] | [348, 414, 158] |
p03317 | u416011173 | 2,000 | 1,048,576 | 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. | ['# -*- coding: utf-8 -*-\n\nimport math\n\n\nN, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\n\nx = A.index(1)\ny = N - x - 1\nans = math.ceil(x / (K - 1)) + \\\n math.ceil((y - ((K - 1) - x % (K - 1))) / (K - 1))\n\n\nprint(ans)\n', '# -*- coding: utf-8 -*-\n\nimport math\n\n\ndef get_input() -> tuple:\n \n \n N, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n\n return N, K, A\n\n\ndef main(N: int, K: int) -> None:\n \n \n ans = math.ceil((N - 1) / (K - 1))\n\n \n print(ans)\n\n\nif __name__ == "__main__":\n \n N, K, A = get_input()\n\n \n main(N, K)\n'] | ['Wrong Answer', 'Accepted'] | ['s862624249', 's779762526'] | [20472.0, 20580.0] | [54.0, 53.0] | [332, 740] |
p03317 | u428132025 | 2,000 | 1,048,576 | 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. | ['import math\n\nn, k = map(int, input().split())\na = [int(_) for _ in input().split()]\n\nif n == k:\n print(1)\n exit()\n\nidx = a.index(1)\nnum_l = idx\nnum_r = n - idx - 1\nprint(num_l, num_r)\n\nif num_l == 0 or num_r == 0:\n print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))\nelif num_l < k-1:\n print(math.ceil(num_l / (k - 1)) + math.ceil((num_r - k + 1 + num_l) / (k - 1)))\nelif num_r < k-1:\n print(math.ceil((num_l - k + 1 + num_r) / (k - 1)) + math.ceil(num_r / (k - 1)))\nelse:\n print(math.ceil(num_l / (k - 1)) + math.ceil(num_r / (k - 1)))\n', 'import math\nn, k = map(int, input().split())\na = [int(_) for _ in input().split()]\nprint(math.ceil((n-1) / (k-1)))'] | ['Wrong Answer', 'Accepted'] | ['s080702922', 's616055501'] | [13812.0, 13812.0] | [44.0, 44.0] | [566, 114] |
p03317 | u440191278 | 2,000 | 1,048,576 | 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. | ["import sys\n\ndef solve(n, k, as):\n return n/(k-1)\n\ndef readQuestion():\n line = sys.stdin.readline().rstrip()\n [str_n, str_k] = line.split(' ')\n line = sys.stdin.readline().rstrip()\n as = line.split(' ')\n return (int(str_n), int(str_k), [int(a) for a in as])\n\ndef main():\n n, k, as = readQuestion()\n answer = solve(n, k, as)\n print(answer)\n \nif __name__ == '__main__':\n main()", "import sys\n\ndef solve(n, k, as1):\n if (n-1)%(k-1)==0:\n return (n-1)//(k-1)\n else:\n return (n-1)//(k-1)+1\n\ndef readQuestion():\n line = sys.stdin.readline().rstrip()\n [str_n, str_k] = line.split(' ')\n line = sys.stdin.readline().rstrip()\n as1 = line.split(' ')\n return (int(str_n), int(str_k), [int(a) for a in as1])\n\ndef main():\n n, k, as1 = readQuestion()\n answer = solve(n, k, as1)\n print(answer)\n \nif __name__ == '__main__':\n main()"] | ['Runtime Error', 'Accepted'] | ['s688629283', 's743630414'] | [2940.0, 14900.0] | [17.0, 44.0] | [411, 484] |
p03317 | u450904670 | 2,000 | 1,048,576 | 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. | ['import math\nN,K = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nans = 1\n\nif(K-1 == 1):\n print(N - 1)\nelse:\n print(N // (K - 1))\nidx = A.index(1)\ncnt = 1\nright = idx\nleft = idx\nwhile True:\n for i in range(1, K):\n right += 1\n if(right < len(A)): \n A[right] = 1\n else:\n left -= 1\n if(0 <= left):\n A[left] = 1\n else:\n print(cnt)\n exit()\n if(left <= 0 and len(A)-1 <= right):\n print(cnt)\n exit()\n else:\n cnt += 1\n', 'import math\nN,K = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nans = 1\n\nidx = A.index(1)\ncnt = 1\nright = idx\nleft = idx\nwhile True:\n for i in range(1, K):\n right += 1\n if(right < len(A)): \n A[right] = 1\n else:\n left -= 1\n if(0 <= left):\n A[left] = 1\n else:\n print(cnt)\n exit()\n if(left <= 0 and len(A)-1 <= right):\n print(cnt)\n exit()\n else:\n cnt += 1\n'] | ['Wrong Answer', 'Accepted'] | ['s455683235', 's390902886'] | [13812.0, 13812.0] | [84.0, 85.0] | [496, 439] |
p03317 | u454714837 | 2,000 | 1,048,576 | 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. | ['N,K = map(int,input().split())\nA = list(input())\n\nAns = N-1//(K-1)\n\nprint(Ans)', 'N,K = map(int,input().split())\nA = list(input())\nAns = 0\n\nif (N-1)%(K-1)==0:\n Ans = Ans = N//(K-1)\nelse:\n Ans = N//(K-1) + 1\n\nprint(Ans)', "N,K = map(int,input().split())\nA = list(input())\nAns = 0\n\nif N == K:\n Ans = 1\nelif K == 2:\n Ans = N -1\nelse:\n if N%(K-1)==0:\n Ans = Ans = N//(K-1)\n else:\n Ans = N//(K-1) + 1\n \ne = A.index('1') \nif e < K or N-e <K:\n Ans = Ans + 1\nprint(Ans)", 'N,K = map(int,input().split())\nA = list(input())\nAns = 0\n\nif (N-1)%(K-1)==0:\n Ans = (N-1)//(K-1)\nelse:\n Ans = (N-1)//(K-1) + 1\n\nprint(Ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s530787708', 's546711105', 's769053476', 's283140290'] | [8756.0, 8756.0, 9140.0, 8756.0] | [27.0, 27.0, 27.0, 30.0] | [78, 142, 281, 145] |
p03317 | u459590249 | 2,000 | 1,048,576 | 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. | ['from math import ceil\nn,k=map(int,input().split())\nprint(ceil(n-1/k-1))', 'from math import ceil\nn,k=map(int,input().split())\nprint(ceil((n-1)/(k-1)))'] | ['Wrong Answer', 'Accepted'] | ['s305880274', 's742575865'] | [3060.0, 3060.0] | [17.0, 17.0] | [71, 75] |
p03317 | u473092610 | 2,000 | 1,048,576 | 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. | ['\n\n\nusing namespace std;\n\nint main(){\n int n,k;\n cin >> n >> k;\n std::vector<char> a(n);\n\n for (int i =0;i<n;i++)\n cin >> a[i];\n int ans =-(-n/(k-1));\n cout << ans<<endl;\n\n\n}', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nn=n-k\nprint(-(-n//(k-1))+1)'] | ['Runtime Error', 'Accepted'] | ['s660010587', 's984346653'] | [2940.0, 14004.0] | [17.0, 39.0] | [232, 89] |
p03317 | u474270503 | 2,000 | 1,048,576 | 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. | ['N, K = map(int, input().split())\n\nA = list(map(int, input().split()))\n\nmin_A = min(A)\n\n\nind1 = A.index(1)\nlen1 = len(A) -ind1\nlen2 = ind1 + 1\nprint((len1-1)//(K-1)-1+1 + (len2-1)//(K-1)-1+1)\n', 'N, K = map(int, input().split())\n\nA = list(map(int, input().split()))\n\nmin_A = min(A)\n\n\nind1 = A.index(1)\nlen1 = N -ind1\nlen2 = ind1 + 1\n\nr1= 0\nif (len1-1)%(K-1) != 0:\n r1 = 1\n\nr2= 0\nif (len2-1)%(K-1) != 0:\n r2 = 1\nd = 0\n\n\n\nans1 = (len1-1)//(K-1)+r1 + (len2-1)//(K-1)+r2\n\nans=[]\nans.append(ans1)\nfor i in range(1, K):\n ans2 = 0\n r3= 0\n if (len1-i-1)%(K-1) != 0:\n r3 = 1\n\n r4= 0\n if (len2-((K-1)-i)-1)%(K-1) != 0:\n r4 = 1\n ans2 = (len1-i-1)//(K-1)+r3 + (len2-((K-1)-i)-1)//(K-1)+r4 + 1\n ans.append(ans2)\n print(i, ans2)\n\n\nprint(min(ans))\n', 'N, K = map(int, input().split())\n\nA = list(map(int, input().split()))\n\nmin_A = min(A)\n\n\nind1 = A.index(1)\nlen1 = N -ind1\nlen2 = ind1 + 1\n\nr1= 0\nif (len1-1)%(K-1) != 0:\n r1 = 1\n\nr2= 0\nif (len2-1)%(K-1) != 0:\n r2 = 1\nd = 0\n\n\n\nans1 = (len1-1)//(K-1)+r1 + (len2-1)//(K-1)+r2\n\nans=[]\nans.append(ans1)\nfor i in range(1, K):\n ans2 = 0\n r3= 0\n if (len1-i-1)%(K-1) != 0:\n r3 = 1\n\n r4= 0\n if (len2-((K-1)-i)-1)%(K-1) != 0:\n r4 = 1\n ans2 = (len1-i-1)//(K-1)+r3 + (len2-((K-1)-i)-1)//(K-1)+r4 + 1\n ans.append(ans2)\n\n\n\nprint(min(ans))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s362483894', 's948395085', 's068694410'] | [13880.0, 14008.0, 14008.0] | [42.0, 273.0, 159.0] | [191, 581, 563] |
p03317 | u488127128 | 2,000 | 1,048,576 | 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. | ['3 3\n1 2 3', "def solve():\n n,k = map(int, input().split())\n if (n-1)%(k-1) != 0:\n return (n-1)//(k-1) + 1\n else:\n return (n-1)//(k-1)\n\nif __name__ == '__main__':\n print(solve())"] | ['Runtime Error', 'Accepted'] | ['s802272775', 's648118931'] | [2940.0, 3060.0] | [17.0, 17.0] | [9, 190] |
p03317 | u497883442 | 2,000 | 1,048,576 | 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. | ['n,k = list(map(int, input().split()))\na = list(map(int, input().split()))\nprint((n-k+1)//(n-1)+1)', 'n,k = list(map(int, input().split()))\na = list(map(int, input().split()))\nprint((n-1)//(k-1))', 'n,k = list(map(int, input().split()))\na = list(map(int, input().split()))\nc = 0\nwhile n > 0:\n if c == 0:\n n -= k\n else:\n n -= k-1\n c += 1\nprint(c)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s080992333', 's201975735', 's635357379'] | [14008.0, 13880.0, 13880.0] | [41.0, 41.0, 49.0] | [97, 93, 155] |
p03317 | u503228842 | 2,000 | 1,048,576 | 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. | ['N,K =map(int,input().split())\nans = (N-1)//(K-1)\nprint(ans)', 'N,K =map(int,input().split())\nans = 1+(N-K)//(K-1)\nprint(ans)', 'N,K = map(int,input().split())\nA = list(map(int,input().split()))\nidx = A.index(1)\nimport math\nans = math.ceil((N-1)/(K-1))\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s558638576', 's851451840', 's021283346'] | [3060.0, 3060.0, 13880.0] | [17.0, 17.0, 41.0] | [59, 61, 134] |
p03317 | u507456172 | 2,000 | 1,048,576 | 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. | ['N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nprint((N-1)//(K-1))', 'N,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nif (N-1)%(K-1) == 0:\n print((N-1)//(K-1))\nelse:\n print((N-1)//(K-1)+1)'] | ['Wrong Answer', 'Accepted'] | ['s670168951', 's650338229'] | [20480.0, 20560.0] | [54.0, 50.0] | [86, 139] |
p03317 | u513081876 | 2,000 | 1,048,576 | 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. | ['N, K = map(int, input().split())\nA = list(map(int, input().split()))\nans = 0\nmin_in = A.index(1)\n\nleft = len(A[0:min_in])\n\nright = len(A[min_in+1:])\n#print(left, right)\nif N ==K:\n ans = 1\n \nelse:\n if (min(left, right) + 1) < K:\n ans += 1\n tuyoi = len(A-K)\n \n ans += tuyoi//K\n \n if tuyoi % K !=0:\n ans +=1\n \n else:\n if left != 0:\n ans += left//(K-1)\n \n if left%(K-1) != 0:\n ans += 1\n \n if right != 0:\n ans += right//(K-1)\n \n if right%(K-1) != 0:\n ans += 1\nprint(ans)', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\nans = 0\nmin_in = A.index(1)\n\nleft = len(A[0:min_in])\n\nright = len(A[min_in+1:])\n\nif N ==K:\n ans = 0\n \nelse:\n if (min(left, right) + 1) < K:\n ans += 1\n tuyoi = len(A-K)\n \n ans += tuyoi//K\n \n if tuyoi % K !=0:\n ans +=1\n \n else:\n if left != 0:\n ans += left//(K-1)\n \n if left%(K-1) != 0:\n ans += 1\n \n if right != 0:\n ans += right//(K-1)\n \n if right%(K-1) != 0:\n ans += 1\nprint(ans)', 'N, K = map(int, input().split())\nA = [int(i) for i in input().split()]\nnum = K\nans = 1\n\nif N <= K:\n print(ans)\nelse:\n while num < N:\n num += K-1\n ans += 1\n print(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s872959473', 's903658119', 's511906821'] | [14008.0, 14008.0, 13880.0] | [41.0, 41.0, 52.0] | [651, 631, 189] |
p03317 | u518042385 | 2,000 | 1,048,576 | 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. | ['n,m=map(int,input().split())\nl=list(map(int,input().split()))\nmin=l[0]\nindex=0\nfor i in range(n):\n if min>l[i]:\n min=l[i]\n index=i\nindex+=1\nindex2=n-index\nsum=0\nsum+=index2//m+1\nindex3=index-1\nsum+=index3//m+1\n ', 'n,m=map(int,input().split())\nl=list(map(int,input().split()))\nif (n-1)%(m-1)==0:\n print((n-1)//(m-1))\nelse:\n print((n-1)//(m-1)+1)\n'] | ['Wrong Answer', 'Accepted'] | ['s459726902', 's222854643'] | [13880.0, 13880.0] | [50.0, 40.0] | [219, 133] |
p03317 | u520276780 | 2,000 | 1,048,576 | 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. | ['\n\n\n\n\n\nn,k = map(int,input().split( ))\nprint((n+k-1)//(k-1))\n', '\nn,k = map(int,input().split( ))\nprint((n+k-3)//(k-1))'] | ['Wrong Answer', 'Accepted'] | ['s708049841', 's066285602'] | [3060.0, 2940.0] | [19.0, 18.0] | [215, 89] |
p03317 | u527261492 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na=list(map(int,input().split()))\nidx=a.index(1)\nprint((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', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\ncnt=1\nn-=k\nwhile n>0:\n n-=k-1\n cnt+=1\nprint(cnt)'] | ['Wrong Answer', 'Accepted'] | ['s496939192', 's001050138'] | [14008.0, 13880.0] | [40.0, 50.0] | [176, 112] |
p03317 | u531214632 | 2,000 | 1,048,576 | 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. | ['N,K = map(int, input().split())\nprint(-(-(N-1))//(K-1))\n', 'import math\nN, K = map(int, input().split())\nprint( 1 + math.ceil((N-K) / (K-1)) )'] | ['Wrong Answer', 'Accepted'] | ['s342551939', 's182543790'] | [2940.0, 3060.0] | [18.0, 17.0] | [56, 82] |
p03317 | u532806301 | 2,000 | 1,048,576 | 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. | ['N,K = map(int, input().split())\nlist = []\nfor i in range(N):\n list.append(int(input()))\n\nprint(-(-(N-1)//(K-1)))', 'N,K = map(int, input().split())\nprint(-(-(N-1)//(K-1)))'] | ['Runtime Error', 'Accepted'] | ['s814981111', 's931667534'] | [4724.0, 3064.0] | [21.0, 17.0] | [115, 55] |
p03317 | u538739837 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na=list(map(int,input().split()))\ncount=1\nn-k\nwhile(n>0):\n n-(k-1)\n count+=1\nprint(count)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\ncount=1\nn=n-k\nwhile(n>0):\n n=n-(k-1)\n count+=1\nprint(count)'] | ['Time Limit Exceeded', 'Accepted'] | ['s821350343', 's275169647'] | [13880.0, 14004.0] | [2104.0, 48.0] | [124, 127] |
p03317 | u545368057 | 2,000 | 1,048,576 | 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. | ['N,K = map(int,input().split())\nAs = list(map(int,input().split()))\nprint((N-1)//(K-1))', 'N,K = map(int, input().split())\nAs = list(map(int, input().split()))\n\nimport numpy as np \nans = np.ceil((N-1)/(K-1))\nprint(int(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s728625514', 's602028365'] | [13880.0, 16424.0] | [40.0, 173.0] | [86, 133] |
p03317 | u551373727 | 2,000 | 1,048,576 | 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. | ['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nprint(N//K)', 'N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\na = (N-2)//(K-1)+1\n\nprint(a)'] | ['Wrong Answer', 'Accepted'] | ['s400296115', 's387942392'] | [13880.0, 13880.0] | [40.0, 39.0] | [81, 98] |
p03317 | u556225812 | 2,000 | 1,048,576 | 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. | ['import math\nN, K = map(int, input().split())\nprint(math.ceil((N-K)/(K-1)))', 'import math\nN, K = map(int, input().split())\nprint(math.ceil((N-1)/(K-1)))'] | ['Wrong Answer', 'Accepted'] | ['s683663307', 's515123291'] | [3060.0, 3060.0] | [17.0, 17.0] | [74, 74] |
p03317 | u556487440 | 2,000 | 1,048,576 | 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. | ['\nimport math\n\nn , k = map(int, input().split())\nb = list(map(int,input().split()))\ncnt = 1\ni = 0\nfor t in b:\n if t == 1:\n i = cnt\n break\n cnt += 1\n\nresult = math.ceil((i-1)/(k-1)) + math.ceil((n-i)/(k-1))\nif ((i-1)/(k-1) - math.floor((i-1)/(k-1))) + ((n-i)/(k-1) - math.floor((n-i)/(k-1))) <= 1:\n result -= 1\n\nprint(result)\n', '\nimport math\n\nn , k = map(int, input().split())\nb = list(map(int,input().split()))\ncnt = 1\ni = 0\nfor t in b:\n if t == 1:\n i = cnt\n break\n cnt += 1\n\nresult = math.ceil((i-1)/(k-1)) + math.ceil((n-i)/(k-1))\nif ((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:\n result -= 1\n\nprint(result)\n'] | ['Wrong Answer', 'Accepted'] | ['s493356161', 's847363394'] | [13812.0, 13812.0] | [47.0, 46.0] | [568, 668] |
p03317 | u570018655 | 2,000 | 1,048,576 | 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. | ['N, K = map(int, input().split())\nl = list(map(int, input().split()))\nindex = l.index(1) + 1\n\nans = 0\n\nif index != 1:\n p = index - K\n ans += 1\n if p < 0:\n index = K\n p += 1\n while p > 0:\n p = p - K\n ans += 1\n\nwhile index < N:\n index = index + (K - 1)\n ans += 1\n\nprint(ans)\n', 'N, K = map(int, input().split())\nl = list(map(int, input().split()))\nindex = l.index(1) + 1\n\nans = 0\n\nif index != 0:\n p = index - K\n ans += 1\n if p < 0:\n index = K\n p += 1\n while p > 0:\n p = p - K\n ans += 1\n\nwhile index < N:\n index = index + (K - 1)\n ans += 1\n\nprint(ans)\n', 'N = int(input())\nK = int(input())\nl = list(map(int, input().split()))\nindex = l.index(1)\n\nans = 0\nif index != 0:\n p = index - K + 1\n ans += 1\n if p < 0:\n index = index + (-1 * p)\n elif p > 0:\n while p > 0:\n p = p - K + 1\n ans += 1\nif index < (N - 1):\n ans += 1\n index = index + K - 1\n while index < (N - 1):\n index = index + K - 1\n ans += 1\n\nprint(ans)', 'from math import ceil\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nans = 1\nN = N - K\nans += ceil(N/(K-1))\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s488079512', 's651448608', 's883711617', 's637023558'] | [20560.0, 20472.0, 9100.0, 13812.0] | [55.0, 52.0, 29.0, 40.0] | [398, 398, 423, 142] |
p03317 | u575653048 | 2,000 | 1,048,576 | 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. | ['import math\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nx = a.index(1)\n#if x % (k-1) + (n-k-1) % (k-1) > k-1:\nprint(math.ceil((n-1) // (k-1)))', 'import math\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nx = a.index(1)\n#if x % (k-1) + (n-k-1) % (k-1) > k-1:\nprint(math.ceil((n-1) / (k-1)))'] | ['Wrong Answer', 'Accepted'] | ['s604836694', 's402581198'] | [13812.0, 13812.0] | [41.0, 40.0] | [167, 166] |
p03317 | u576320075 | 2,000 | 1,048,576 | 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. | ['import math\n\n\n\na = list(map(int, input().split()))\nn -= 1\nk -= 1\nans = (n + k - 1) // k\n\nprint(ans)\n', 'import math\n\nn, k = map(int, input().split())\n\n# a = list(map(int, input().split()))\nn -= 1\nk -= 1\nans = (n + k - 1) // k\n\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s815752976', 's208210919'] | [3060.0, 3060.0] | [17.0, 19.0] | [134, 134] |
p03317 | u578489732 | 2,000 | 1,048,576 | 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. | ["# -*- coding: utf-8 -*-\nimport sys\n# ----------------------------------------------------------------\n# Use Solve Function\n\ndef solve(lines):\n N,K = map(int, lines.pop(0).split(' '))\n A = list(map(int, lines.pop(0).split(' ')))\n min_a = min(A)\n idx = 0\n re = 0\n while( idx < N ):\n if ( all([i == min_a for i in A[idx:idx+K] ]) ):\n idx += K - 1\n continue\n else:\n re += 1\n idx += K - 1\n print(re)\n\n\n\n#\n# main\n#\n\n# 1. use list instead of stdin\n\n# contents = '''\\\n# 10 3\n# 7 3 2 1 1 1 1 5 5 5\\\n# '''\n\n# \n# 2. use stdin\n\nlines = [x.strip() for x in sys.stdin.readlines()]", "# -*- coding: utf-8 -*-\nimport sys\n# ----------------------------------------------------------------\n# Use Solve Function\n\ndef solve(lines):\n N,K = map(int, lines.pop(0).split(' '))\n A = list(map(int, lines.pop(0).split(' ')))\n min_a = min(A)\n idx = 0\n re = 0\n while( idx < N - 1):\n if ( all([i == min_a for i in A[idx:idx+K] ]) ):\n idx += K - 1\n continue\n else:\n re += 1\n idx += K - 1\n print(re)\n\n\n\n#\n# main\n#\n\n# 1. use list instead of stdin\n\n#contents = '''\\\n#3 3\n#1 2 3\\\n#'''\n\n# \n# 2. use stdin\n\nlines = [x.strip() for x in sys.stdin.readlines()]\n\n#\n# solve !!\n#\nsolve(lines)"] | ['Wrong Answer', 'Accepted'] | ['s095325684', 's154594306'] | [4272.0, 13872.0] | [19.0, 74.0] | [675, 687] |
p03317 | u578953945 | 2,000 | 1,048,576 | 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. | ['N,K=map(int,input.split())\nTMP=K\nANS=1\nif N <= K:\n ANS=1\nelse:\n TMP+=(K-1)\n ANS+=1\n if N <= K:\n break\nprint(ANS)\n', 'N,K=map(int,input.split())\nTMP=K\nANS=1\nif N =< K:\n ANS=1\nelse:\n TMP=(K-1)\n ANS+=1\n if N <= K:\n break\nprint(ANS)\n', 'N,K=map(int,input.split())\nTMP=K\nANS=1\nif N <= K:\n ANS=1\nelse:\n TMP=(K-1)\n ANS+=1\n if N <= K:\n break\nprint(ANS)\n', 'N,K=map(int,input().split())\nTMP=K\nANS=1\nif N <= K:\n ANS=1\nelse:\n while True:\n TMP+=(K-1)\n ANS+=1\n if N <= TMP:\n break\nprint(ANS)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s137842109', 's316242156', 's993477728', 's378713709'] | [2940.0, 2940.0, 2940.0, 3060.0] | [17.0, 17.0, 17.0, 28.0] | [120, 119, 119, 145] |
p03317 | u595289165 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input().split())\na = list(map(int, input().split()))\nx = a.index(1)\nleft = x\nright = n - x - 1\n\nans = n\nfor i in range(k):\n if left < i:\n continue\n a = left - i + 1\n if right - k + 2 + i < 0:\n continue\n b = right - k + 2 + i\n print(a, b)\n w = a//(k-1) + b//(k-1)\n ans = min(ans, w)\nprint(ans + 1)\n\n', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\n\n\ndef ceil(x, y):\n if x % y == 0:\n return x // y\n else:\n return x // y + 1\n\n\nprint(ceil(n-1, k-1))\n'] | ['Wrong Answer', 'Accepted'] | ['s449209194', 's412878952'] | [13880.0, 13880.0] | [110.0, 40.0] | [349, 188] |
p03317 | u597374218 | 2,000 | 1,048,576 | 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. | ['n,k=map(int,input().split())\na=len(list(map(int,input().split())))\nprint((n-k-3)//(k-1))', 'n,k=map(int,input().split())\na=len(list(map(int,input().split())))\nprint((n+k-3)//(k-1))'] | ['Wrong Answer', 'Accepted'] | ['s120436804', 's646829978'] | [13880.0, 13880.0] | [41.0, 39.0] | [88, 88] |
p03317 | u600935366 | 2,000 | 1,048,576 | 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. | ['n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(int((k-1)/(n-1)))', 'n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(int((n-1)/(k-1)))\n', 'import math\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(math.ceil((n-1)/(k-1)))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s361963204', 's740905157', 's254375552'] | [13812.0, 13880.0, 13812.0] | [40.0, 40.0, 39.0] | [93, 94, 111] |
p03317 | u609061751 | 2,000 | 1,048,576 | 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. | ['import sys\nimport numpy as np\ninput = sys.stdin.readline\nN, K = [int(x) for x in input().split()]\nA = np.array([int(x) for x in input().split()],np.int64)\nans = 0\ncnt = 0\nminA = np.argmin(A)\nleftA = A[:minA]\nrightA = A[minA+1:]\nx = len(leftA)\ny = len(rightA)\nfor i in [x,y]:\n ans += i // (K-1)\n cnt += i % (K-1)\nif cnt % (K-1) == 0:\n ans += cnt % (K-1)\nelse:\n ans += 1 + cnt % (K-1)\nprint(ans)', 'import sys\nimport numpy as np\ninput = sys.stdin.readline\nN, K = [int(x) for x in input().split()]\nA = np.array([int(x) for x in input().split()],np.int64)\nans = 0\ncnt = 0\nminA = np.argmin(A)\nleftA = A[:minA]\nrightA = A[minA+1:]\nx = len(leftA)\ny = len(rightA)\nfor i in [x,y]:\n ans += i // (K-1)\n cnt += i % (K-1)\nif cnt % (K-1) == 0:\n ans += cnt // (K-1)\nelse:\n ans += 1 + cnt // (K-1)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s081859316', 's965009498'] | [23480.0, 23440.0] | [183.0, 182.0] | [405, 407] |
p03317 | u611509859 | 2,000 | 1,048,576 | 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. | ['import math\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nprint(math.floor((n-1+(n%(k-1)))//(k-1)))', 'import math\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nif (n-1) % (k-1) == 0:\n print(math.floor((n-1)/(k-1)))\nelse:\n print(math.floor((n-1)/(k-1))+1)'] | ['Wrong Answer', 'Accepted'] | ['s906300898', 's395056064'] | [13812.0, 13812.0] | [39.0, 39.0] | [122, 181] |
p03317 | u614627871 | 2,000 | 1,048,576 | 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. | ['N = int(input())\ndsum = 0\ntmp = N\nwhile tmp > 0:\n dsum += tmp % 10\n tmp /= 10\n tmp = int(tmp)\nif N % dsum != 0:\n print ("No")\nelse:\n print ("Yes")', 'import math\ndef main():\n line_input = input().split()\n n = int(line_input[0])\n k = int(line_input[1])\n nums = input().split()\n print(math.ceil((n - 1) / (k - 1)))\n\nmain()\n'] | ['Runtime Error', 'Accepted'] | ['s059201264', 's712568473'] | [3060.0, 10420.0] | [18.0, 26.0] | [153, 186] |
p03317 | u615710615 | 2,000 | 1,048,576 | 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. | ['#!/usr/bin/env python\n# -*- coding:utf-8 -*-\n\nN,K = map(int,input().split(" "))\nA = list(map(int, input().split(" ")))\n\nF=0\nfor i in A:\n if i==1:\n X=F \n Y=N-(F+1)\n break;\n F=F+1\n\nqX=X//(K-1)\nqY=Y//(K-1)\n\nmodX=X%(K-1)\nmodY=Y%(K-1)\n\nprint(F,qX,qY,modX,modY)\nif modX>0:\n AnsX = qX+1\nelse:\n AnsX=qX\n\nif modY>0:\n AnsY=qY+1\nelse:\n AnsY=qY\nprint(AnsX+AnsY)', '#!/usr/bin/env python\n# -*- coding:utf-8 -*-\n\nN,K = map(int,input().split(" "))\nA = list(map(int, input().split(" ")))\n\nF=0\nfor i in A:\n if i==1:\n X=F \n Y=N-(F+1)\n break;\n F=F+1\n\nP=(X+Y)//(K-1)\nif (X+Y)%(K-1)>0:\n print(P+1)\nelse:\n print(P)'] | ['Wrong Answer', 'Accepted'] | ['s439233542', 's783592463'] | [13880.0, 14008.0] | [46.0, 49.0] | [388, 272] |
p03317 | u618512227 | 2,000 | 1,048,576 | 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. | ['n , k = map(int, input().split())\nif k == 2:\n print(n-1)\nelif k == n-1:\n print(2)\nelif n%2 != 0 k%2 == 0 and (n-k)%(k-1) != 0:\n \tprint(n//(k-1) + 1)\nelse:\n print(n//(k-1))', 'n , k = map(int, input().split())\nif k == 2:\n print(n-1)\nelif k == n-1:\n print(2)\nelif (n-k)%(k-1) == 0:\n print((n-k)//(k-1) +1)\nelse:\n print((n-k)//(k-1) + 2)'] | ['Runtime Error', 'Accepted'] | ['s809180263', 's429089083'] | [2940.0, 3060.0] | [17.0, 23.0] | [181, 171] |
p03317 | u622277165 | 2,000 | 1,048,576 | 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. | ['# -*- coding:utf-8 -*-\nn, k = list(map(int, input().split()))\nnums = list(map(int, input().split()))\none_index = nums.index(1)\nmin = n\nfor i in range(k):\n left = one_index - i\n right = len(nums[one_index+1:]) - (k - i)\n if left + right > n-1:\n break\n else:\n min_tmp = (-(-left//(k-1)))+(-(-right//(k-1)))\n if min > min_tmp:\n min = min_tmp\nprint(min)\n', '# -*- coding:utf-8 -*-\nimport math\nn, k = list(map(int, input().split()))\nnums = list(map(int, input().split()))\none_index = nums.index(1)\nif k == len(nums):\n print(1)\nelse:\n print(math.ceil((n-1)/(k-1)))\n'] | ['Wrong Answer', 'Accepted'] | ['s457024634', 's470391865'] | [13812.0, 13812.0] | [2104.0, 40.0] | [394, 211] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.