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
|
---|---|---|---|---|---|---|---|---|---|---|
p03308 | u898421873 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['value = []\nfor part in input().split():\n value.append(int(part))\n\nprint(max(value) - min(value))', 'N = int(input())\n \nvalue = []\nfor part in input().split():\n value.append(int(part))\n \nprint(max(value) - min(value))'] | ['Wrong Answer', 'Accepted'] | ['s868151009', 's520230339'] | [3064.0, 2940.0] | [17.0, 17.0] | [99, 125] |
p03308 | u901687869 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N = int(input())\nNlist = input().split()\n\nwMax = Nlist(0)\nwMin = Nlist(0)\nfor value in Nlist:\n if int(value) > wMax:\n wMax = int(value)\n if int(value) < wMin:\n wMin = int(value)\n\nprint(abs(wMax - wMin))', 'N = int(input())\nNlist = input().split()\n\nwMax = int(Nlist[0])\nwMin = int(Nlist[0])\nfor value in Nlist:\n if int(value) > wMax:\n wMax = int(value)\n if int(value) < wMin:\n wMin = int(value)\n\nprint(abs(wMax - wMin))'] | ['Runtime Error', 'Accepted'] | ['s566215650', 's258763054'] | [3060.0, 3060.0] | [17.0, 17.0] | [222, 232] |
p03308 | u903596281 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N=int(input())\nA=[int(x) for x in input().split()]\nans=0\nfor i in range(N):\n for j in range(i+1,N):\n ans=max(ans,abs(A[i]-A[j])\nprint(ans)', 'N=int(input())\nA=[int(x) for x in input().split()]\nans=0\nfor i in range(N):\n for j in range(i+1,N):\n ans=max(ans,abs(A[i]-A[j]))\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s777246857', 's146744064'] | [2940.0, 3060.0] | [17.0, 19.0] | [142, 143] |
p03308 | u908763441 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N = int(input())\nA = list(map(int,input().split())\nprint(max(A)-min(A))', 'N = int(input())\nA = list(map(int,input().split()))\nprint(max(A)-min(A))'] | ['Runtime Error', 'Accepted'] | ['s129708632', 's756496701'] | [2940.0, 2940.0] | [17.0, 17.0] | [71, 72] |
p03308 | u911516631 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N = int(input())\nA = input().split()\nprint(max(A)-min(A))', 'N = int(input())\nA = list(map(int, input().split()))\nprint(max(A)-min(A))\n'] | ['Runtime Error', 'Accepted'] | ['s545619712', 's101512492'] | [9060.0, 9104.0] | [26.0, 30.0] | [57, 74] |
p03308 | u914762730 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['input()\na=map(int,input().split())\nprint(max(a)-min(a))\n', 'input()\na=list(map(int,input().split()))\nprint(max(a)-min(a))\n'] | ['Runtime Error', 'Accepted'] | ['s170496977', 's903880467'] | [2940.0, 2940.0] | [17.0, 17.0] | [56, 62] |
p03308 | u935264791 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['#! /usr/bin/env python\n# coding: UTF-8\n\nn = (int)(input())\nlist = list(int(i) for i in input().split())\nprint(list)\nmx = max(list)\nmn = min(list)\nprint(mx - mn)', '#! /usr/bin/env python\n# coding: UTF-8\n\nn = (int)(input())\nlist = list(int(i) for i in input().split())\nmx = max(list)\nmn = min(list)\nprint(mx - mn)'] | ['Wrong Answer', 'Accepted'] | ['s967062100', 's714272881'] | [2940.0, 2940.0] | [19.0, 17.0] | [160, 148] |
p03308 | u941753895 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['n=int(input())\na=[]\nfor i in range(n):\n a.append(int(input()))\nprint(max(a)-min(a))', '\nN=input()\nl=list(map(int,input().split()))\n\nmx=0\nfor x in l:\n for y in l:\n mx=max(mx,abs(x-y))\n\n\nprint(mx)'] | ['Runtime Error', 'Accepted'] | ['s362965675', 's215421272'] | [2940.0, 2940.0] | [18.0, 20.0] | [84, 127] |
p03308 | u944015274 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['import math\ninput()\nx = list(map(int, input().split()))\nprint(math.max(x) - math.min(x))', 'input()\nx = list(map(int, input().split()))\nprint(max(x) - min(x))'] | ['Runtime Error', 'Accepted'] | ['s871986901', 's231677372'] | [3060.0, 2940.0] | [17.0, 17.0] | [88, 66] |
p03308 | u944600619 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['input;n=list(map(int,input().split()))\nprint(max(n) - min(n))', 'input;n=list(map(itn,input().split()))\nprint(max(n) - min(n))', 'input();n=list(map(int,input().split()))\nprint(max(n) - min(n))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s632941216', 's661438960', 's376903707'] | [2940.0, 2940.0, 2940.0] | [17.0, 17.0, 17.0] | [61, 61, 63] |
p03308 | u952968889 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N = int(input())\n\nnum = 1\n\nwhile(N >= num*2):\n num *= 2\n\nprint(num)', 'N = int(input())\nlis = [int(i) for i in input().split()]\n\nlis.sort()\n\nprint(lis[len(lis)-1] - lis[0])'] | ['Wrong Answer', 'Accepted'] | ['s913043992', 's929603964'] | [2940.0, 2940.0] | [17.0, 17.0] | [70, 101] |
p03308 | u955251526 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['n = int(input())\na = list(map(int, input().split()))\nreturn max(a) - min(a)', 'n = int(input())\na = list(map(int, input().split()))\nprint(max(a) - min(a))'] | ['Runtime Error', 'Accepted'] | ['s291203273', 's415958951'] | [2940.0, 2940.0] | [17.0, 18.0] | [75, 75] |
p03308 | u960570220 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N = int(input())\nA = list(map(int, input()).split())\n\nprint(max(A) - min(N))', 'N = int(input())\nA = list(map(int, input().split()))\n\nprint(max(N) - min(N))', 'N = int(input())\nA = list(map(int, input().split()))\n\nprint(max(A) - min(A))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s610151027', 's632692978', 's876847435'] | [9016.0, 9040.0, 8944.0] | [26.0, 24.0, 29.0] | [76, 76, 76] |
p03308 | u961288441 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N =int(input()) \nA =list(map(int, input(\n \nprint(max(A)-min(A))', 'N =int(input())\nA =list(map(int, input().split()))\nprint(max(A)-min(A))'] | ['Runtime Error', 'Accepted'] | ['s085173182', 's364360942'] | [2940.0, 2940.0] | [17.0, 17.0] | [92, 71] |
p03308 | u962415921 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N=int(input())\nA=map(int, input().split())\nmaxnum=max(A)\nminnum=min(A)\nprint(maxnum-minnum)', 'N=int(input())\nA=map(int, input().split())\nmaxnum=max(A)\nminnum=min(A)\nprint(maxnum-minnum)\n', 'N=int(input())\nA=list(map(int, input().split()))\nprint(max(A)-min(A))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s150866829', 's264134535', 's783244306'] | [2940.0, 2940.0, 2940.0] | [18.0, 17.0, 17.0] | [91, 92, 70] |
p03308 | u963903527 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['\nn = input()\nl = input()\nprint(abs(max(l) - min(l)))', '\nn = input()\na = input().split(" ")\n\nl = list()\nfor x in a:\n\tl.append(int(x))\n\nprint(abs(max(l) - min(l)))'] | ['Runtime Error', 'Accepted'] | ['s918676309', 's289934045'] | [2940.0, 2940.0] | [17.0, 17.0] | [52, 106] |
p03308 | u970738863 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['N = int(input())\nA = list(map(int,input().split()))\n\nasorted = sorted(A)\nprint(asorted[N+1]-asorted[0])', 'N = int(input())\nA = list(map(int,input().split()))\n\nasorted = sorted(A)\nprint(asorted[N]-asorted[0])\n', 'N = int(input())\nA = list(map(int,input().split()))\n\nasorted = sorted(A)\nprint(asorted[N-1]-asorted[0])\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s847538714', 's928893484', 's590894378'] | [2940.0, 2940.0, 2940.0] | [18.0, 17.0, 17.0] | [103, 102, 104] |
p03308 | u972892985 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['n = int(input())\na = list(map(int,input().split()))\nprint(abs(min(a)-max(a))', 'n = int(input())\na = list(map(int,input().split()))\nprint(abs(min(a)-max(a)))'] | ['Runtime Error', 'Accepted'] | ['s741506736', 's161858498'] | [2940.0, 2940.0] | [17.0, 17.0] | [76, 77] |
p03308 | u977642052 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['def main(n, a):\n ans = 0\n for i, j in permutations(a, 2):\n ans = max(ans, i - j)\n\n print(ans)\n\n\nif __name__ == "__main__":\n n = int(input())\n a = list(map(int, input().split()))\n\n main(n, a)\n', 'from itertools import permutations\n\n\ndef main(n, a):\n ans = 0\n for i, j in permutations(a, 2):\n ans = max(ans, i - j)\n\n print(ans)\n\n\nif __name__ == "__main__":\n n = int(input())\n a = list(map(int, input().split()))\n\n main(n, a)\n'] | ['Runtime Error', 'Accepted'] | ['s080989760', 's452432765'] | [2940.0, 3060.0] | [17.0, 19.0] | [216, 253] |
p03308 | u993268357 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['list = [int(i) for i in input()]\nprint(max(max(list)-min(list)))', 'n = input()\nlist = [int(i) for i in input().split()]\nprint(abs(max(list)-min(list)))'] | ['Runtime Error', 'Accepted'] | ['s641910661', 's947567479'] | [2940.0, 2940.0] | [18.0, 17.0] | [64, 84] |
p03308 | u994521204 | 2,000 | 1,048,576 | You are given an integer sequence A of length N. Find the maximum absolute difference of two elements (with different indices) in A. | ['n=int(input())\nA=list(map(int,input().split()))\nprint(abs((max(A)-min(A))', 'n=int(input())\nA=list(map(int,input().split()))\nprint(abs(max(A)-min(A)))'] | ['Runtime Error', 'Accepted'] | ['s830020890', 's023892838'] | [2940.0, 2940.0] | [17.0, 17.0] | [73, 73] |
p03309 | u006657459 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ["import math\nN = int(input())\nA = [int(x) for x in input().split(' ')]\ndef score(A, b):\n s = 0\n for i, Ai in enumerate(A):\n s = math.abs(Ai - i - b)\n return s\ns = math.inf\nfor b in range(min(A), max(A)):\n si = score(A, b)\n if si < s:\n s = si\nprint(s)", "import statistics\nN = int(input())\nA = [int(x) for x in input().split(' ')]\ndef score(C, b):\n s = 0\n for i, Ci in enumerate(C):\n s += abs(Ci - b)\n return int(s)\n\nC = [Ai - (i+1) for i, Ai in enumerate(A)]\nb = statistics.median(C)\nb1 = int(b)\nb2 = int(b) + 1\ns1 = score(C, b1)\ns2 = score(C, b2)\nprint(min(s1, s2))"] | ['Runtime Error', 'Accepted'] | ['s849768125', 's484890889'] | [26832.0, 27236.0] | [73.0, 255.0] | [278, 328] |
p03309 | u013408661 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n=int(input())\na=list(map(int,input().split()))\nfor i in range(n):\n a[n]-=i\nx=sum(a)//n\nans=0\nfor i in a:\n ans+=abs(i-x)\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nfor i in range(n):\n a[n]-=i\nx=sum(a)//n\nans=0\nfor i in a:\n ans+=abs(i-b)\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nfor i in range(n):\n a[n]-=i\nx=sum(a)//n\nans=0\nfor i in a:\n ans+=abs(i-x)\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nb=[0]\nc=[0]\ncount=0\ncount2=0\nfor i in range(n):\n a[i]-=i\nfor i in range(n-1):\n count+=a[i+1]-a[i]\n b.append(count)\nfor i in range(n-1):\n count2+=b[i+1]-b[i]\n c.append(count2)\nans=10**18\nfor i in range(n):\n ans=min(ans,c[-1]-i*c[i])\nprint(ans)', 'n=int(input())\na=list(map(int,input().split()))\nb=[0]\nc=[0]\ncount=0\ncount2=0\nfor i in range(n):\n a[i]-=i\nfor i in range(n-1):\n count+=a[i+1]-a[i]\n b.append(count)\nfor i in range(n-1):\n count2+=b[i+1]\n c.append(count2)\nans=10**18\nfor i in range(n):\n ans=min(ans,c[-1]-c[i]-b[i]*(n-i-1))\nprint(ans)', 'n=int(input())\na=[int(i) for i in input().split()]\na=[a[i]-(i+1) for i in range(n)]\na.sort()\nif n%2==0:\n print(sum(a[n//2:])-sum(a[0:n//2]))\nelse:\n print(sum(a[n//2+1:])-sum(a[0:n//2]))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s014703586', 's164469533', 's317546045', 's606332390', 's915201274', 's049756215'] | [26708.0, 26832.0, 26180.0, 27372.0, 28800.0, 25200.0] | [67.0, 67.0, 67.0, 333.0, 332.0, 182.0] | [133, 133, 133, 296, 302, 191] |
p03309 | u017624958 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\nfor i in range(len(A)):\n A[i] -= (i + 1)\n# print(A)\n\n# _A = list(map(abs, A))\n\naverage = math.floor(sum(A) / len(A)) - 1\n\nfor i in range(len(A)):\n A[i] = abs(A[i] - average)\n\nsadness = sum(A)\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\n_A = [] * len(A)\nfor i in range(len(A)):\n _A[i] -= (i + 1)\n_A.sort()\nmedian = _A[len(A) / 2]\n\nsadness = 0\nfor i in range(len(A)):\n sadness += abs(A[i] - (i + 1 + median))\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\nfor i in range(len(A)):\n A[i] -= (i + 1)\n\nleft = -abs(min(A))\nright = abs(max(A))\nminimum = right\n\nfor b in range(left, right + 1):\n sadness = 0\n for Ai in A:\n sadness = abs(Ai - b)\n\n minimum = min(sadness, minimum)\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\nfor i in range(len(A)):\n A[i] -= (i + 1)\n# print(A)\n\naverage = math.ceil(sum(A) / len(A))\n\nfor i in range(len(A)):\n A[i] = abs(A[i] - average)\n\nsadness = sum(A)\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\nfor i in range(len(A)):\n A[i] -= (i + 1)\n# print(A)\n\n# _A = list(map(abs, A))\n\naverage = math.floor(sum(A) / len(A)) + 1\n\nfor i in range(len(A)):\n A[i] = abs(A[i] - average)\n\nsadness = sum(A)\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\nfor i in range(len(A)):\n A[i] -= (i + 1)\n# print(A)\n\n_A = map(abs, A)\n_A = list(A)\n\naverage = math.ceil(sum(_A) / len(_A))\n\nfor i in range(len(A)):\n A[i] = abs(A[i] - average)\n\nsadness = sum(A)\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\nfor i in range(len(A)):\n A[i] -= (i + 1)\n# print(A)\n\n_A = list(map(abs, A))\n\naverage = math.ceil(sum(_A) / len(_A))\n\nfor i in range(len(A)):\n A[i] = abs(A[i] - average)\n\nsadness = sum(A)\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\n_A = [A[i] - (i + 1) for i in range(len(A))]\n_A.sort()\nmedian = _A[math.ceil(len(A) / 2)]\n\nsadness = 0\nfor i in range(len(A)):\n sadness += abs(A[i] - (i + 1 + median))\n\nprint(sadness)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n# print(N, A)\n\n_A = [A[i] - (i + 1) for i in range(len(A))]\n_A.sort()\nmedian = _A[math.floor(len(A) / 2)]\n\nsadness = 0\nfor i in range(len(A)):\n sadness += abs(A[i] - (i + 1 + median))\n\nprint(sadness)\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s291495901', 's356264600', 's385720916', 's528765971', 's552571422', 's564983387', 's675373001', 's827172208', 's811185350'] | [26832.0, 26832.0, 26832.0, 25964.0, 26832.0, 26832.0, 26832.0, 26832.0, 26832.0] | [149.0, 74.0, 2105.0, 147.0, 154.0, 152.0, 159.0, 228.0, 234.0] | [295, 274, 355, 264, 295, 297, 290, 268, 269] |
p03309 | u023229441 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n=int(input())\nA=list(map(int,input().split()))\nq=0\nZ=[]\nfor b in range(len(A)):\n q=0\n for j in A:\n q+=abs(j-b-1)\n Z.append(q)\nprint(min(Z))\n', 'n=int(input())\nA=list(map(int,input().split()))\nq=0\nZ=[]\nfor b in range(len(A)):\n for j in A:\n q+=abs(j-b-1)\n Z.append(q)\nprint(min(Z))', 'n=int(input())\nA=list(map(int,input().split()))\nq=0\nZ=[]\nfor b in range(max(A)-min(A)):\n q=0\n for j in range(n):\n q+=abs(A[j]-b-min[A]-j-1)\n Z.append(q)\nprint(min(Z))\n', 'n=int(input())\nA=list(map(int,input().split()))\nq=0\nZ=[]\nfor b in range(max(A)):\n q=0\n for j in range(n):\n q+=abs(A[j]-b-j-1)\n Z.append(q)\nprint(min(Z))\nprint(Z)', 'n=int(input())\nA=list(map(int,input().split()))\nq=0\nZ=[]\nt=min(A)\nfor b in range(int((max(A)-min(A))//2)):\n q=0\n for j in range(n):\n q+=abs(A[j]-b-t-j-1)\n Z.append(q)\nprint(min(Z))\n', 'import sys\nimport math\nmod=10**9+7\ninf=float("inf")\nfrom math import sqrt\nfrom collections import deque\nfrom collections import Counter\ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom functools import lru_cache\n\n\n\n\nn=int(input())\nA=list(map(int,input().split()))\nSA=[0 for i in range(n)]\nfor i in range(n):\n SA[i]=A[i]-i-1\nSA.sort()\n\nif n%2==0:\n geta=(SA[n//2]+SA[n//2-1])//2\nelse:\n geta=SA[n//2]\nans=0\nfor i in range(n):\n ans+= abs(A[i]-(geta+i+1))\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s208161419', 's444229759', 's607462916', 's697200688', 's956780950', 's486033661'] | [26832.0, 26180.0, 26836.0, 127112.0, 26020.0, 26892.0] | [2104.0, 2104.0, 74.0, 2111.0, 2104.0, 271.0] | [147, 140, 173, 167, 187, 666] |
p03309 | u038027079 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n = int(input())\nan = list(map(int, input().split()))\na = []\nsu = 0\nfor i in range(n):\n a.append(an[i] - i+1) \na.sort()\nb = a[n//2]\nfor i in range(n):\n su += abs(an[i] - (int(b) + i))\nprint(su)', 'import statistics as s\nn = int(input())\nan = list(map(int, input().split()))\na = []\nsum = 0\nfor i in range(n):\n a.append(an[i] - i+1) \nb = s.median(a)\nfor i in range(n):\n sum += abs(an[i] - (b + i)) \nprint(int(sum))', 'n = int(input())\nan = list(map(int, input().split()))\nsu = 0\nfor i in range(n):\n an[i] -= i+1\nan.sort()\nb = an[n//2]\nfor i in range(n):\n an[i] -= b\n an[i] = abs(an[i])\nprint(sum(an))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s082795372', 's608146425', 's740715508'] | [26128.0, 27236.0, 26708.0] | [277.0, 278.0, 254.0] | [195, 218, 185] |
p03309 | u044952145 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import statistics\n\nN = int(input())\nA = [int(c) for c in input().split()]\nA = [abs(n - (b+i+1)) for i, n in enumerate(A)]\n\nb = int(statistics.median(A))\nprint(sum([abs(n - b) for n in A]))', 'import statistics\n\nN = int(input())\nA = [int(c) for c in input().split()]\nA = [n - (i+1) for i, n in enumerate(A)]\n\nb = int(statistics.median(A))\nprint(sum([abs(n - b) for n in A]))'] | ['Runtime Error', 'Accepted'] | ['s770488426', 's003750521'] | [27256.0, 27256.0] | [93.0, 212.0] | [188, 181] |
p03309 | u057429331 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int, input().split()))\nmax = max(A)\nlist = []\nx = 0\nfor i in range(N):\n A[i] = A[i] -i\nsum = 0\nfor i in range(N):\n sum = sum + A[i]\nave = int(sum/N)\nfor i in range(N):\n x = x + abs(A[i]-ave-1)\nprint(x)\n', 'N = int(input())\nA = list(map(int, input().split()))\nfor i in range(N):\n A[i] = A[i] - i - 1\nA = sorted(A)\nmedN = N//2\n\nx = 0\nfor i in range(N):\n x = x + abs(A[i] - A[halfN])\nprint(x)\n', 'N = int(input())\nA = list(map(int, input().split()))\nmax = max(A)\nlist = []\nx = 0\nfor i in range(N):\n A[i] = A[i] -i\nsum = 0\nfor i in range(N):\n sum = sum + A[i]\nave = int(sum/N)\nfor i in range(N):\n x = x + abs(A[i]-ave-i)\nprint(x)\n', 'N = int(input())\nA = list(map(int, input().split()))\nfor i in range(N):\n A[i] = A[i] - i - 1\nA = sorted(A)\nmedN = N//2\n\nx = 0\nfor i in range(N):\n x = x + abs(A[i] - A[medN])\nprint(x)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s278108469', 's808034324', 's917194468', 's575688886'] | [26836.0, 26708.0, 26836.0, 25200.0] | [186.0, 190.0, 191.0, 247.0] | [241, 190, 241, 188] |
p03309 | u065079240 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import math\nN = int(input())\nA = [int(x) for x in input().split()]\nsum = 0\nA_prime = [0]*N\nfor i in range(N):\n A_prime[i] = A[i] - i - 1\n sum += A_prime[i]\n\n# print(sum)\nave = math.ceil(sum / N)\n# print(ave)\nans = 0\nfor k in range(N):\n ans += abs(A[k] - (ave + k + 1))\nprint(ans)\n', '\n\nN = int(input())\nA = [int(x) for x in input().split()]\nA_prime = [0]*N\nfor i in range(N):\n A_prime[i] = A[i] - i-1\nA_prime = sorted(A_prime)\ncenter = A_prime[N//2]\n\nans = 0\nfor k in range(N):\n ans += abs(A[k] - (center + k + 1))\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s373895610', 's617860750'] | [26832.0, 25200.0] | [207.0, 253.0] | [305, 277] |
p03309 | u068400994 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['# coding: utf-8\n# Your code here!\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA_i = [0]*N\nK = [0] * 101\n\nfor i in range(N):\n A_i[i] = A[i] - i - 1\n\nb_0 = sum(A_i) / len(A_i)\nb = [0] * 101\nb[0] = int(b_0)\nfor i in range(1,101):\n b[i] = b[0] + int(i - 50.5)\nprint(b)\n\nfor i in range(N):\n for j in range(11):\n K[j] = K[j] + abs(A_i[i] - b[j])\n\nprint(min(K))', '# coding: utf-8\n# Your code here!\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA_i = [0]*N\nK = [0] * 101\n\nfor i in range(N):\n A_i[i] = A[i] - i - 1\n\nb_0 = sum(A_i) / len(A_i)\nb = [0] * 101\nb[0] = int(b_0)\nfor i in range(1,101):\n b[i] = b[0] + int(i - 50.5)\n\nfor i in range(N):\n for j in range(11):\n K[j] = K[j] + abs(A_i[i] - b[j])\n\nprint(min(K))\n', '# Your code here!\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA_i = [0]*N\nK = [0] * 101\n\nfor i in range(N):\n A_i[i] = A[i] - i - 1\n\nb_0 = sum(A_i) / len(A_i)\nb = [0] * 101\nb[0] = int(b_0)\nfor i in range(1,101):\n b[i] = b[i] + int(i - 50.5)\n\n\nfor i in range(N):\n for j in range(11):\n K[j] = K[j] + abs(A_i[i] - b[j])\n\nprint(min(K))', '# coding: utf-8\n# Your code here!\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA_i = [0]*N\nK = [0] * 101\n\nfor i in range(N):\n A_i[i] = A[i] - i - 1\n\nb_0 = sum(A_i) / len(A_i)\nb = [0] * 101\nb[0] = int(b_0)\nfor i in range(1,101):\n b[i] = b[0] + int(i - 50.5)\nprint(b)\nfor i in range(N):\n for j in range(101):\n K[j] = K[j] + abs(A_i[i] - b[j])\nprint(K)\n\nprint(min(K))', 'import statistics\nimport math\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA_i = [0]*N\nK_1 = 0\nK_2 = 0\nK_3 = 0\n\n\nfor i in range(N):\n A_i[i] = A[i] - i - 1\n\ntry:\n b_1 = statistics.mode(A_i)\nexcept:\n b_1 = int(statistics.mean(A_i))\n\nb_2= int(statistics.mean(A_i))\nb_3 = int(statistics.median(A_i))\n\nfor i in range(N):\n K_1 = K_1 + abs(A_i[i] - b_1)\n K_2 = K_2 + abs(A_i[i] - b_2)\n K_3 = K_3 + abs(A_i[i] - b_3)\n\nprint(min(K_1, K_2, K_3))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s296219033', 's321980519', 's650766117', 's690900006', 's760743179'] | [25708.0, 26180.0, 25708.0, 26180.0, 49260.0] | [901.0, 904.0, 897.0, 2105.0, 609.0] | [383, 375, 359, 392, 465] |
p03309 | u074445770 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N=int(input())\na=list (map(int,input().split()))\nabs_list=[]\nfor b in range(-max(a),max(a)):\n\tc=0\n\tfor i in range(N):\n\t\tc=abs(a[i]-(b+i+1))+c\t\n\tabs_list.append(c)\t\nprint(abs_list)\t\nprint(min(abs_list))\t', 'N=int(input())\na=list (map(int,input().split()))\nabs_list=[]\nfor b in range(-max(a),max(a)):\n\tc=0\n\tfor i in range(N):\n\t\tc=abs(a[i]-(b+i+1))+c\t\n\tabs_list.append(c)\t\nprint(abs_list)\t\nprint(min(abs_list))\t', 'N=int(input())\na=list (map(int,input().split()))\nabs_list=[]\nc=0\nfor i in range(N):\n\tc=(a[i]-(i+1))\n\tabs_list.append(c)\nabs_list.sort()\nb=abs_list[int(N/2)]\t\nd=0\nfor i in range(N):\n\td=abs(abs_list[i]-b)+d\t\t\nprint(d)\t'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s160808597', 's904228282', 's041296871'] | [144920.0, 137112.0, 26836.0] | [2113.0, 2112.0, 252.0] | [202, 202, 216] |
p03309 | u078349616 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['\nN = int(input())\nA = list(map(int, input().split()))\nave = sum(A) / N\n\np = []\nfor i in range(N):\n p.append(i+1)\np_ave = sum(p) / N\n\nb = round(ave - p_ave)\n\nans = 0\nfor i in range(N):\n ans += abs(A[i] - (b + i))\nprint(ans)', '\nN = int(input())\nA = list(map(int, input().split()))\n\nbl = []\nfor i in range(N):\n bl.append(A[i] - (i+1))\nbl.sort()\nif N % 2 == 0:\n b = (bl[N//2-1] + bl[N//2]) // 2\nelse:\n b = bl[N//2]\n\nans = 0\nfor i in range(N):\n ans += abs(A[i] - (b + (i+1)))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s679203457', 's930981295'] | [26836.0, 25200.0] | [157.0, 247.0] | [261, 301] |
p03309 | u079656139 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from statistics import median\nN = int(input())\nA = list(map(int, input().split()))\nB = list()\nsad = 0\n\nfor i in range(N):\n B.append(A[i]-i)\n\nb = median(B)\n\nfor i in range(N):\n sad = sad + abs(A[i] - (b+i))\n\nprint(int(sad))\nprint(median(A))', 'from statistics import median\nN = int(input())\nA = list(map(int, input().split()))\nB = list()\nsad = 0\n\nfor i in range(N):\n B.append(A[i]-i)\n\nb = median(B)\n\nfor i in range(N):\n sad = sad + abs(A[i] - (b+i))\n\nprint(int(sad))'] | ['Wrong Answer', 'Accepted'] | ['s488833892', 's148079889'] | [27236.0, 27260.0] | [359.0, 276.0] | [241, 224] |
p03309 | u083960235 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['#from collections import Counter\nimport math\nN=int(input())\nA=list(map(int,input().split()))\nl=[]\nn=1\nfor i in A:\n l.append(i-n)\n n+=1\nl.sort()\n\n\nc=int(math.floor(N/2))\nb=A[c]\nans_l=[]\nans=0\nfor j in l:\n ans+=abs(j-l[b])\n\nprint(ans)', '#from collections import Counter\nimport math\nN=int(input())\nA=list(map(int,input().split()))\nl=[]\nn=1\nfor i in A:\n l.append(i-n)\n n+=1\nl.sort()\n\n\nc=int(math.floor(N/2))\n\nans_l=[]\nans=0\nfor j in l:\n ans+=abs(j-l[c])\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s484176347', 's675365479'] | [26832.0, 26832.0] | [183.0, 230.0] | [264, 258] |
p03309 | u106297876 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import statistics\nN = int(input())\nA = list(map(int, input().split()))\n\nfor i in range(N):\n\tA[i] = A[i] - (i+1)\nA.sort()\n\nb = statistics.median(A)\n\nans = 0\n\nfor i in range(N):\n\tans += abs(A[i] - b)\nprint(ans', 'import statistics\nN = int(input())\nA = list(map(int, input().split()))\n\nfor i in range(N):\n\tA[i] = A[i] - (i+1)\nA.sort()\n\nif N % 2 == 0:\n\tmed1 = A[N // 2 - 1]\n\tmed2 = A[N //2]\n\tans = min(sum([abs(a - med1) for a in A]), sum([abs(a - med2) for a in A]))\n\nelse:\n\tmed = A[N // 2]\n\tans = sum([abs(a - med) for a in A])\n\t\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s571552275', 's200521267'] | [3060.0, 27244.0] | [17.0, 251.0] | [207, 327] |
p03309 | u107091170 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N=int(input())\nA=list(map(int,input().split()))\nfor i in range(N):\n A[i] = A[i] - i - 1\nprint( A.sum() // N )\n', 'N=int(input())\nA=list(map(int,input().split()))\nfor i in range(N):\n A[i] = A[i] - i - 1\nA.sort()\nb = A[N//2]\nans = 0\nfor i in range(N):\n ans += abs(A[i] - b)\nprint(ans)\n \n'] | ['Runtime Error', 'Accepted'] | ['s162142909', 's809991798'] | [25196.0, 26708.0] | [108.0, 225.0] | [111, 174] |
p03309 | u131411061 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int,input().split()))\n\nres = 0\nb = A[N//2 - 1] - (N//2)\nprint(b)\nfor i in range(N):\n res += abs((i+b+1) - A[i])\nprint(res)', 'N = int(input())\nA = list(map(int,input().split()))\n\n\nfor i in range(N):\n A[i] = A[i]-i-1\nA.sort()\nb = A[N//2]\nprint(sum(list(map(lambda x:abs(x-b),A))))\n'] | ['Wrong Answer', 'Accepted'] | ['s249201572', 's566177770'] | [26832.0, 26708.0] | [130.0, 231.0] | [155, 252] |
p03309 | u136090046 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import math\n\nn = int(input())\narray = [int(x) for x in input().split()]\narray2 = [array[x]-(x+1) for x in range(n)]\n\nb_ = array2[n//2]\nb_1 = array2[n//2+1]\nb_2 = array2[n//2-1]\n\nres = [abs(array[x]-(b_+x+1)) for x in range(n)]\nres1 = [abs(array[x]-(b_1+x+1)) for x in range(n)]\nres2 = [abs(array[x]-(b_2+x+1)) for x in range(n)]\nprint(min(sum(res)), sum(res1), sum(res2))\n\n', 'n = int(input())\narray = [int(x) for x in input().split()]\narray2 = [x-(i+1) for i, x in enumerate(array)]\n\nb_ = sorted(array2)[n//2]\n\nres = [abs(array[x]-(b_+x+1)) for x in range(n)]\nprint(sum(res))\n\n'] | ['Runtime Error', 'Accepted'] | ['s559542871', 's697253628'] | [43976.0, 27616.0] | [218.0, 213.0] | [373, 201] |
p03309 | u140251125 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import statistics\n\n# input\nN = int(input())\nA = list(map(int, input().split()))\n\nfor i in range(N):\n A[i] = A[i] - (i + 1)\n\nb = median_low(A)\nans = 0\n\nfor i in range(N):\n ans += abs(A[i] - b)\n\nprint(ans)\n\n', 'from statistics import median_low\n\n# input\nN = int(input())\nA = list(map(int, input().split()))\n\nfor i in range(N):\n A[i] = A[i] - (i + 1)\n\nb = median_low(A)\nans = 0\n\nfor i in range(N):\n ans += abs(A[i] - b)\n\nprint(ans)\n\n'] | ['Runtime Error', 'Accepted'] | ['s191698231', 's473577459'] | [27244.0, 27236.0] | [129.0, 242.0] | [211, 227] |
p03309 | u161537170 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import math\nimport statistics\nimport numpy as np\nsize = int(input())\nA = np.array(list(map(int,input().split())))\ni = np.array(list(range(1,size+1)))\n\nremain_list = A-i\nmedian = statistics.median(remain_list)\nprint(sum(remain_list - median))A', 'import math\nimport statistics\nimport numpy as np\nsize = int(input())\nA = np.array(list(map(int,input().split())))\ni = np.array(list(range(1,size+1)))\n\nremain_list = A-i\nmedian = statistics.median(remain_list)\nprint(sum(remain_list - median))A\n', 'size = int(input())\nA = list(map(int,input().split()))\ni = list(range(1,size+1))\n\nremain_list = [A-i for(A,i) in zip(A,i)]\nprint(remain_list)\nwhile(True):\n zero_count = len([i for i in remain_list if i ==0])\n minus_count = len([i for i in remain_list if i <0])\n plus_count = len([i for i in remain_list if i > 0])\n\n if zero_count == max(zero_count,minus_count,plus_count) or plus_count == minus_count:\n break\n\n if plus_count == max(zero_count,minus_count,plus_count):\n remain_list = [num - 1 for num in remain_list]\n\n if minus_count == max(zero_count,minus_count,plus_count):\n remain_list = [num + 1 for num in remain_list]\n\n\nsum_list =[abs(num) for num in remain_list]\nprint(sum_list)\nprint(sum(sum_list))\n', 'import math\nimport statistics\nimport numpy as np\nsize = int(input())\nA = np.array(list(map(int,input().split())))\ni = np.array(list(range(1,size+1)))\n\nremain_list = A-i\nmedian = statistics.median(remain_list)\nprint(int(sum(abs(remain_list - median))))\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s412077395', 's465335133', 's726147859', 's628051433'] | [2940.0, 2940.0, 40152.0, 35168.0] | [17.0, 17.0, 2106.0, 424.0] | [242, 243, 746, 252] |
p03309 | u170183831 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from math import floor\n\ndef solve(n, A):\n A.sort()\n b = A[n // 2 + 1]\n return sum(abs(a - (b + i + 1)) for i, a in enumerate(A))\n\n_n = int(input())\n_A = list(map(int, input().split()))\nprint(solve(_n, _A))\n', 'from math import floor\n\ndef solve(n, A):\n B = sorted([a - (i + 1) for i, a in enumerate(A)])\n b = B[n // 2]\n ret = sum(abs(a - (b + i + 1)) for i, a in enumerate(A))\n if n % 2 == 0:\n b = B[n // 2 + 1]\n tmp = sum(abs(a - (b + i + 1)) for i, a in enumerate(A))\n if tmp < ret:\n ret = tmp\n return ret\n\n_n = int(input())\n_A = list(map(int, input().split()))\nprint(solve(_n, _A))\n'] | ['Runtime Error', 'Accepted'] | ['s938508762', 's481923318'] | [26832.0, 26608.0] | [186.0, 249.0] | [215, 421] |
p03309 | u177040005 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import numpy as np\nimport collections as col\nimport math\nN = int(input())\nA = list(map(int, input().split()))\n\nnpA = np.array(A)\nnpi = np.arange(1,N+1)\ndiff = npA - npi\n\nave = np.sum(diff) // (N+1)\ndiff2 = diff - ave\nans1 = np.sum(abs(diff2))\n\nans2 = 0\ntmp = 0\ntmp_befor = ans1\nb_tmp = ave\nwhile True:\n if b_tmp >= 0:\n b_tmp += 1\n else:\n b_tmp -= 1\n diff2 = 0\n diff2 = diff - b_tmp\n tmp = np.sum(abs(diff2))\n if tmp_befor < tmp:\n break\n tmp_befor = tmp\n ans2 = tmp\n\nif ans1 > ans2:\n print(ans2)\nelse:\n print(ans1)\n', 'import numpy as np\nN = int(input())\nA = list(map(int, input().split()))\n\nnpA = np.array(A)\nnpi = np.arange(1,N+1)\ndiff = npA - npi\nnpA = np.sort(npA)\n\nif N%2 == 0:\n bi = int(N / 2 - 1)\nelse:\n bi = int((N-1) / 2)\n\nprint(np.sum(abs(npA - A[bi])))\n', 'import numpy as np\nimport collections as col\nN = int(input())\nA = list(map(int, input().split()))\n\nnpA = np.array(A)\nnpi = np.arange(1,N+1)\ndiff = npA - npi\n\nave = np.sum(diff) // (N+1)\nprint(ave)\ndiff2 = diff - ave\nans1 = np.sum(abs(diff2))\n\n\nc = col.Counter(diff)\nmost = c.most_common()[0][0]\ndiff3 = diff - most\nans2 = np.sum(abs(diff3))\n\nif ans1 > ans2:\n print(ans2)\nelse:\n print(ans1)\n', 'import numpy as np\nN = int(input())\nA = list(map(int, input().split()))\n\nnpA = np.array(A)\nnpi = np.arange(1,N+1)\ndiff = npA - npi\ndiff = np.sort(diff)\n\nif N%2 == 0:\n bi = int(N / 2 - 1)\n b = (diff[bi] + diff[bi+1])//2\nelse:\n bi = int((N-1) / 2)\n b = diff[bi]\ntmp = diff - b\nans = np.sum(abs(tmp))\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s019853946', 's513773907', 's763137350', 's712148053'] | [34236.0, 34176.0, 60500.0, 34224.0] | [2112.0, 225.0, 605.0, 226.0] | [565, 251, 396, 321] |
p03309 | u177411511 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import sys\nfrom collections import deque\nfrom collections import Counter\nimport statistics\nimport math\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline()\n\nn = ni()\na_li = na()\nfor i in range(n):\n a_li[i] = a_li[i] - (i + 1)\nm1 = statistics.median_low(a_li)\n#m2 = statistics.median_high(a_li)\nans1 = 0\n#ans2 = 0\nfor i in range(n):\n ans1 += abs(a_li[i] - m1)\n #ans2 += abs(a_li[i] - m2)\nprint(min(ans1))\n', 'import sys\nfrom collections import deque\nfrom collections import Counter\nimport statistics\nimport math\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline()\n\nn = ni()\na_li = na()\nfor i in range(n):\n a_li[i] = a_li[i] - (i + 1)\nm1 = statistics.median_high(a_li)\n#m2 = statistics.median_high(a_li)\nans1 = 0\n#ans2 = 0\nfor i in range(n):\n ans1 += abs(a_li[i] - m1)\n #ans2 += abs(a_li[i] - m2)\nprint(ans1)\n'] | ['Runtime Error', 'Accepted'] | ['s944918872', 's783348285'] | [27272.0, 27252.0] | [243.0, 243.0] | [487, 483] |
p03309 | u193264896 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ["\nfrom scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree\nfrom scipy.sparse import csr_matrix, coo_matrix, lil_matrix\nimport numpy as np\nfrom functools import reduce\n\nfrom collections import deque, Counter, defaultdict\nfrom itertools import product, permutations,combinations\nfrom operator import itemgetter\nfrom heapq import heappop, heappush\nfrom bisect import bisect_left, bisect_right, bisect\nfrom fractions import gcd\nfrom math import ceil,floor, sqrt, cos, sin, pi, factorial\nimport statistics\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nMOD = 10**9+7\ndef lcm(a, b):\n return a*b//gcd(a, b)\n\ndef main():\n n = int(readline())\n a = np.array(readline().split(), dtype='int64')\n for i in range(n):\n a[i] -= i+1\n median = np.median(a)\n a -= median\n print(np.abs(a).sum())\n \n \n \n \n \nif __name__ == '__main__':\n main()", "import sys\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nimport numpy as np\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n n = int(readline())\n a = np.array(readline().split(), np.int64)\n a -= np.arange(1, n + 1)\n median = np.median(a).astype(np.int64)\n\n print(np.abs(a - median).sum())\n\n\n\nif __name__ == '__main__':\n main()\n\n"] | ['Wrong Answer', 'Accepted'] | ['s152865549', 's001036748'] | [27800.0, 40104.0] | [476.0, 146.0] | [1014, 393] |
p03309 | u199295501 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['# -*- coding: utf-8 -*-\n\nN = int(input())\nAn = list(map(int, input().split()))\n\nsubA = []\nsub_dic = {}\nfor i in range(N):\n tmp = An[i]-(i+1)\n subA.append(tmp)\n if tmp in sub_dic:\n sub_dic[tmp] += 1\n else:\n sub_dic[tmp] = 1\n\n\nprint(subA)\nprint(sub_dic)\n\nif max(sub_dic.values()) == 1:\n min_v = 0\n for v in subA:\n min_v += abs(v)\n print(min_v)\n\nelse:\n\n max_sub_k = max([(v,k) for k,v in sub_dic.items()])[1]\n\n min_v = 0\n for k,v in sub_dic.items():\n min_v += (k - max_sub_k) * v\n\n print(abs(min_v))\n', '# -*- coding: utf-8 -*-\n\nN = int(input())\nAn = list(map(int, input().split()))\n\nsubA = []\nsub_dic = {}\nfor i in range(N):\n tmp = An[i]-(i+1)\n subA.append(tmp)\n if tmp in sub_dic:\n sub_dic[tmp] += 1\n else:\n sub_dic[tmp] = 1\n\nsubB = {}\nfor k,v in sub_dic.items():\n subB[k] = abs(k*v)\n# print(subA)\n# print(sub_dic)\n\nif max(sub_dic.values()) == 1:\n min_v = 0\n for v in subA:\n min_v += abs(v)\n print(min_v)\n\nelse:\n\n max_sub_k = max([(v,k) for k,v in subB.items()])[1]\n\n min_v = 0\n for k,v in sub_dic.items():\n min_v += (k - max_sub_k) * v\n\n print(abs(min_v))\n', '# -*- coding: utf-8 -*-\n\nN = int(input())\nAn = list(map(int, input().split()))\n\ndef sunuke(An,b):\n ret = 0\n for i,Ai in enumerate(An):\n ret += abs(Ai - (b + i + 1))\n\n return ret\n\nsAn = []\nfor i,Ai in enumerate(An):\n sAn.append(Ai - (i+1))\n\nsAn.sort()\n\nif N % 2 == 0:\n \n center_idx1 = N // 2 - 1\n b1 = sAn[center_idx1]\n center_idx2 = center_idx1 + 1\n b2 = sAn[center_idx2]\n # print(b1,b2)\n print(min([sunuke(An,b1),sunuke(An,b2)]))\nelse:\n \n center_idx = (N+1) // 2 - 1\n b = sAn[center_idx]\n # print(b)\n print(sunuke(An,b))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s594023328', 's843973591', 's705507092'] | [57916.0, 74904.0, 25744.0] | [340.0, 388.0, 280.0] | [558, 619, 610] |
p03309 | u201234972 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from statistics import mean\nimport math\nN = int(input())\n*A, = map(int, input().split())\nB = [A[i]-i for i in range(N)]\nbm = math.median(B)\nK = [x - bm for x in B]\nKZ = [abs(x) for x in K]\nZ = sum(KZ)\nfor i in range(200):\n C = [abs(x-i+100) for x in K]\n Z = min([sum(C),Z])\nprint(int(Z))', 'from statistics import mean\nimport math\nN = int(input())\n*A, = map(int, input().split())\nB = [A[i]-i for i in range(N)]\nbm = median(B)\nK = [x - bm for x in B]\nKZ = [abs(x) for x in K]\nZ = sum(KZ)\nfor i in range(200):\n C = [abs(x-i+100) for x in K]\n Z = min([sum(C),Z])\nprint(int(Z))', 'from statistics import median\nimport math\nN = int(input())\n*A, = map(int, input().split())\nB = [A[i]-i for i in range(N)]\nb = median(B)\nbm = math.floor(b)\nbM = math.ceil(b)\nBm = [abs(x - bm) for x in B]\nBM = [abs(x - bM) for x in B]\nm = sum(Bm)\nM = sum(BM)\nprint(int(min([m,M])))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s444311948', 's669303456', 's036016346'] | [27236.0, 27236.0, 36780.0] | [131.0, 107.0, 229.0] | [293, 288, 279] |
p03309 | u210827208 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['a,b,c=map(int,input().split())\n\nX=[a,b,c]\nX.sort()\nx=X[2]\ny=X[1]\nz=X[0]\n\n\nsabun1=x-y\nsabun2=x-z\n\nif sabun1%2==0 and sabun2%2==0:\n res=(sabun1+sabun2)/2\nelif sabun1%2==1 and sabun2%2==1:\n res=(sabun1//2+sabun2//2)+1\nelif sabun1%2==0 and sabun2%2==1:\n res=(sabun1/2)+(sabun2//2)+2\nelse:\n res=(sabun1//2)+(sabun2/2)+2\n\nprint(int(res))', 'n=int(input())\n\nX=list(map(int,input().split()))\nY=[]\nfor i in range(n):\n Y.append(X[i]-(i+1))\nY.sort()\nres_1=0\n\nif n%2==1:\n m=Y[int((n-1)/2)]\n for j in range(n):\n res_1+=abs(Y[j]-m)\nelse:\n m=(Y[int(n/2)-1]+Y[int(n/2)])//2\n for j in range(n):\n res_1+=abs(Y[j]-m)\n \n\n \nprint(res_1)\n'] | ['Runtime Error', 'Accepted'] | ['s952677162', 's163674795'] | [3064.0, 26180.0] | [18.0, 237.0] | [343, 324] |
p03309 | u220345792 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int, input().split()))\n\nfor i in range(N):\n A[i] -= i+1\n\nA.sort()\nprint(A)\nif N % 2 == 0:\n median = A[N//2]\nelse:\n median = A[(N + 1)//2]\n\nfor i in range(N):\n A[i] -= median\nprint(sum(A))', 'N = int(input())\nA = list(map(int, input().split()))\n\nfor i in range(N):\n A[i] -= i+1\n\nA.sort()\nmedian = A[N//2]\n\nfor i in range(N):\n A[i] -= median\n A[i] = abs(A[i])\nprint(sum(A))\n'] | ['Runtime Error', 'Accepted'] | ['s142975102', 's584784190'] | [26836.0, 26708.0] | [279.0, 271.0] | [229, 190] |
p03309 | u220843654 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['# -*- coding: utf-8 -*-\n\ndata = list(map(int, input().split()))\n\n\nlis = [data[i-1]-i for i in range(1, len(data)+1)]\n\n\nlis.sort()\nmed = lis[len(lis)//2]\n\n\nreslis = [abs(i - med) for i in lis]\n\n\nprint(sum(reslis))\n', '# -*- coding: utf-8 -*-\n\ninput()\ndata = list(map(int, input().split()))\n\n\nlis = [data[i-1]-i for i in range(1, len(data)+1)]\n\n\nlis.sort()\nmed = lis[len(lis)//2]\n\n\nreslis = [abs(i - med) for i in lis]\n\n\nprint(sum(reslis))\n'] | ['Wrong Answer', 'Accepted'] | ['s607612673', 's379249903'] | [3060.0, 26860.0] | [17.0, 194.0] | [312, 320] |
p03309 | u223646582 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N=int(input())\nA=sorted([int(i) for i in input().split()])\n\ndef median(seq):\n s = sorted(seq)\n if len(s) % 2 == 0: \n return (s[len(s) // 2] + s[(len(s) // 2) - 1]) / 2\n else:\n return s[len(s) // 2] \n\nb=median(A)\n\nans=0\nfor i in range(len(A)):\n ans+=abs(A[i]-(b+i+1))\n\nprint(ans)', 'N=int(input())\nA=[int(i) for i in input().split()]\nB=sorted([A[j]-j-1 for j in range(N)])\n\ndef median(seq):\n s = sorted(seq)\n if len(s) % 2 == 0: \n return (s[len(s) // 2] + s[(len(s) // 2) - 1]) / 2\n else:\n return s[len(s) // 2] \n\nb=median(B)\n\nans=0\nfor i in range(N):\n ans+=abs(A[i]-(b+i+1))\n\nprint(int(ans))'] | ['Wrong Answer', 'Accepted'] | ['s153239934', 's416736824'] | [26180.0, 26180.0] | [251.0, 274.0] | [393, 424] |
p03309 | u224554402 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import math\nn = int(input())\nls = list(map(int,input().split()))\nbs = [ls[i]-i-1 for i in range(n)]\nbs.sort()\nprint(bs)\nif n %2 ==0:\n a = round(n/2)\n #print(a)\n can = [bs[a],bs[a-1]]\nelif n ==1:\n can = [bs[0],bs[0]]\nelse:\n a = math.floor(n/2)\n #print(a)\n can = [bs[a+1],bs[a-1]]\n\n#print(can)\nresult = 10**10\nfor k in range(can[1],can[0]+1,1):\n ans =0\n for kn in bs:\n ans += abs(kn-k)\n \n result = min(result, ans)\nprint(result) ', 'import math\nn = int(input())\nls = list(map(int,input().split()))\nbs = [ls[i]-i-1 for i in range(n)]\nbs.sort()\n#print(bs)\nif n %2 ==0:\n a = round(n/2)\n #print(a)\n can = [bs[a],bs[a-1],math.floor((bs[a] +bs[a-1])/2),math.ceil((bs[a] +bs[a-1])/2)]\nelif n ==1:\n can = [bs[0],bs[0]]\nelse:\n a = math.floor(n/2)\n #print(a)\n can = [bs[a+1],bs[a-1],bs[a]]\n\n#print(can)\nresult = 10**27\nfor k in can:\n ans =0\n for kn in bs:\n ans += abs(kn-k)\n #print(ans)\n result = min(result, ans)\n \nprint(result) '] | ['Wrong Answer', 'Accepted'] | ['s564075637', 's324300890'] | [33388.0, 32080.0] | [2208.0, 277.0] | [471, 532] |
p03309 | u225642513 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\na_list = [int(i) for i in input().split()]\na_list.sort()\nb1,b2 = a_list[N//2-1], a_list[N//2]\nc1,c2 = 0,0\nfor i in range(N):\n c1 += abs(a_list[i] - (b1 + i + 1))\nfor i in range(N):\n c2 += abs(a_list[i] - (b2 + i + 1))\nprint(min(c1,c2))', 'N = int(input())\na_list = [int(i) for i in input().split()]\nb_list = [0 for i in range(N)]\nfor i in range(N):\n b_list[i] = a_list[i] - (i + 1)\nb_list.sort()\nb1,b2 = b_list[N//2-1], b_list[N//2]\nc1,c2 = 0,0\nfor i in range(N):\n c1 += abs(a_list[i] - (b1 + i + 1))\nfor i in range(N):\n c2 += abs(a_list[i] - (b2 + i + 1))\nprint(min(c1,c2))'] | ['Wrong Answer', 'Accepted'] | ['s804468809', 's267523800'] | [25196.0, 26180.0] | [300.0, 328.0] | [258, 344] |
p03309 | u228223940 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n = int(input())\na = [int(i) for i in input().split()]\n\nval = []\n\nfor i in range(n):\n val.append(a[i]-i)\n\nval.sort()\nprint(val)\n\n#idx = [(val[0],0)]\nidx = []\ncnt = 1\nfor i in range(n-1):\n if val[i] == val[i+1]:\n #cnt += 1\n if i == n-2:\n idx.append((val[i],i+2))\n continue\n else:\n if i == n-2:\n idx.append((val[i],i+1))\n idx.append((val[i+1],i+2))\n else:\n idx.append((val[i],i+1)) \n #cnt = 1\n \nans_val = 0\nans2_val = 0\n\nfor i in range(len(idx)):\n if idx[i][1] >= (n) // 2:\n ans_val = idx[i][0]\n \n break\n\n#print(idx,ans_val,ans2_val)\n#exit()\n \nans = 0\n#ans2 = 0\n#ans3 = 0\nfor i in range(n):\n ans += abs(a[i]-ans_val-i)\n #ans2 += abs(a[i]-ans_val-i+1)\n #ans3 += abs(a[i]-ans_val-i-1)\n \n\nprint(ans)', 'n = int(input())\na = [int(i) for i in input().split()]\n\nval = []\n\nfor i in range(n):\n val.append(a[i]-i)\n\nval.sort()\nprint(val)\n\n#idx = [(val[0],0)]\nidx = []\ncnt = 1\nfor i in range(n-1):\n if val[i] == val[i+1]:\n #cnt += 1\n if i == n-2:\n idx.append((val[i],i+2))\n continue\n else:\n idx.append((val[i],i+1))\n #cnt = 1\n \nans_val = 0\n\nfor i in range(len(idx)):\n if idx[i][1] >= (n) // 2:\n ans_val = idx[i-1][0]\n\n#print(ans_val)\n#exit()\n \nans = 0\nans2 = 0\nfor i in range(n):\n ans += abs(a[i]-ans_val-i)\n ans2 += abs(a[i]-ans_val-i+1)\n \n\nprint(min(ans,ans2))', 'n = int(input())\na = [int(i) for i in input().split()]\n\nif n == 1:\n print(0)\n exit()\n\nval = []\n\nfor i in range(n):\n val.append(a[i]-i)\n\nval.sort()\n#print(val)\n\n#idx = [(val[0],0)]\nidx = []\ncnt = 1\nfor i in range(n-1):\n if val[i] == val[i+1]:\n #cnt += 1\n if i == n-2:\n idx.append((val[i+1],i+2))\n continue\n else:\n if i == n-2:\n idx.append((val[i],i+1))\n idx.append((val[i+1],i+2))\n else:\n idx.append((val[i],i+1)) \n #cnt = 1\n \nans_val = 0\nans2_val = 0\nans3_val = 0\n\nflag2 = False\nflag3 = False\n\nfor i in range(len(idx)):\n if idx[i][1] >= (n+1) // 2:\n ans_val = idx[i][0]\n """\n #print(i-1)\n if i-1 >= 0:\n flag2 = True\n ans2_val = idx[i-1][0]\n \n if i+1 <= len(idx)-1:\n flag3 = True\n ans3_val = idx[i+1][0]\n """\n break\n\n#print(idx,ans_val,ans2_val)\n#exit()\n \nans = 0\nans2 = 10**20\nans3 = 10**20\nfor i in range(n):\n ans += abs(a[i]-ans_val-i)\n if flag2 == True:\n ans2 += abs(a[i]-ans2_val-i)\n if flag3 == True:\n ans3 += abs(a[i]-ans3_val-i)\n \n\n\nprint(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s471400975', 's810124016', 's683481539'] | [42248.0, 42948.0, 39620.0] | [411.0, 495.0, 408.0] | [949, 636, 1190] |
p03309 | u235084192 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int, input().split()))\n\nA = sorted([a - i for a, i in enumerate(A)])\n\nprint(sum(abs(x-y) for x,y in zip(A, A[::-1]))/2)', 'N = int(input())\nA = list(map(int, input().split()))\n\nA = sorted([a - i for a, i in enumerate(A)])\n\nprint(sum(abs(x-y) for x,y in zip(A, A[::-1]))//2)'] | ['Wrong Answer', 'Accepted'] | ['s316318448', 's090715666'] | [26128.0, 26132.0] | [201.0, 201.0] | [149, 150] |
p03309 | u239528020 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['#!/usr/bin/env python3\n\nn = int(input())\na = list(map(int, input().split()))\n\nprint(a)\na = [j-(i+1) for i, j in enumerate(a)]\n\na.sort()\n\nprint(a)\n', '#!/usr/bin/env python3\n\nn = int(input())\na = list(map(int, input().split()))\n\na = [j-(i+1) for i, j in enumerate(a)]\n\na.sort()\n\nb = a[n//2]\n\nans = 0\nfor i in a:\n ans += abs(i-b)\n\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s502923663', 's531221733'] | [30984.0, 30836.0] | [163.0, 161.0] | [146, 193] |
p03309 | u248670337 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from statistics import median as m\nn=int(input())\nA=list(map(int,input().split()))\nB=sorted([A[i]-i-1 for i in range(n)])\nm(B)=mb\nprint(int(sum([abs(b-mb) for b in B])))', 'from statistics import median as m\nn=int(input())\nA=list(map(int,input().split()))\nB=sorted([A[i]-i-1 for i in range(n)])\nmb=m(B)\nprint(int(sum([abs(b-mb) for b in B])))'] | ['Runtime Error', 'Accepted'] | ['s254778882', 's709365815'] | [2940.0, 28824.0] | [17.0, 230.0] | [169, 169] |
p03309 | u265939044 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import sys\nimport math\nN = input()\nAList = list(map(int, input().split()))\nlistnum = 1000000000\n\nlow = -1000000000\nhigh = 1000000000\n\nmode = 1\na1 = 0\na2 = 0\nwhile(True):\n p1 = math.floor((abs(low) + abs(high))/3) + low\n p2 = math.floor((abs(low) + abs(high))*2/3) + low\n\n for j in range(1,int(N)+1):\n a1 += abs(AList[j-1] -(p1 + j))\n for j in range(1,int(N)+1):\n a2 += abs(AList[j-1] -(p2 + j))\n if a1 == a2 or abs(a1-a2) == 1:\n print(min(a1,a2))\n sys.exit()\n elif a1 < a2:\n high = p2 - 1\n else:\n low = p1 + 1 \n a1 = 0\n a2 = 0', 'from statistics import median\nN = int(input())\nAList = list(map(int, input().split()))\n \nL = []\nm = 0\nfor j in range(1, N+1):\n L.append(AList[j-1] - j)\nm = median(L)\n \np = 0\nfor j in range(1, N+1):\n p += abs(AList[j-1] - j - m)\n \nprint(int(p))'] | ['Wrong Answer', 'Accepted'] | ['s978435449', 's467790910'] | [26608.0, 27248.0] | [2104.0, 264.0] | [602, 249] |
p03309 | u271044469 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n = int(input())\na = list(map(int, input().split()))\n\nb = []\n\nfor i in range(n):\n b.append(a[i]-(i+1))\n\n# print(b)\nb.sort()\n# print(b)\n\nmin_b=b[n//2]\nprint(min_b)\n\nans = 0\nfor i in range(n):\n ans+=abs(a[i]-(min_b+(i+1)))\n # print(ans)\nprint(ans)', 'n = int(input())\na = list(map(int, input().split()))\n\nb = []\n\nfor i in range(n):\n b.append(a[i]-(i+1))\n\n# print(b)\nb.sort()\n# print(b)\n\nmin_b=b[n//2]\n# print(min_b)\n\nans = 0\nfor i in range(n):\n ans+=abs(a[i]-(min_b+(i+1)))\n # print(ans)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s997769377', 's660686228'] | [26836.0, 25196.0] | [258.0, 247.0] | [248, 250] |
p03309 | u273201018 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import statistics\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nA = [a - i for i, a in enumerate(A)]\n\nM = int(statistics.median(A_b))\nR = []\n\nfor m in [M-2. M-1, M, M+1, M+2]:\n R.append(sum([abs(a - m) for a in A]))\n\nprint(min(R))\n', 'import statistics\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nA = [a - i for i, a in enumerate(A)]\n\nM = int(statistics.median(A_b))\nR = []\n\nfor m in [M-2, M-1, M, M+1, M+2]:\n R.append(sum([abs(a - m) for a in A]))\n\nprint(min(R))\n', 'import statistics\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nA = [a - i for i, a in enumerate(A)]\n\nM = int(statistics.median(A))\nR = []\n\nfor m in [M-2, M-1, M, M+1, M+2]:\n R.append(sum([abs(a - m) for a in A]))\n\nprint(min(R))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s412825029', 's695396335', 's862866166'] | [2940.0, 27244.0, 27240.0] | [18.0, 105.0, 277.0] | [244, 244, 242] |
p03309 | u278670845 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import math\nn = int(input())\na = [0]*n\nfor i,x in enumerate(map(int, input().split())):\n a[i]=x-i-1\n\ndef my_round2(val, digit=0):\n p = 10 ** digit\n s = math.copysign(1, val)\n return (s * val * p * 2 + 1) // 2 / p * s\nave = my_round2(sum(a)/n)\nans = sum(abs(x-ave) for x in a)\nprint(ans)', 'import statistics\nn = int(input())\na = [0]*n\nfor i,x in enumerate(map(int, input().split())):\n a[i]=x-i-1\n\nc = int(statistics.median(a))\n\nans = sum(abs(x-c) for x in a)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s667882447', 's921182570'] | [26832.0, 28464.0] | [141.0, 223.0] | [296, 180] |
p03309 | u278864208 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nAS = input().split()\nfor i in AS:\n i = int(i)\nb = 0\na = int(max(AS))\nc = -int(max(AS))\nold_list = []\nwhile(not ( b in old_list)): \n result_a = 0\n result_c = 0\n for j in range (1, N+1):\n result_a += abs(int(AS[j-1]) - a - j)\n for j in range (1, N+1):\n result_c += abs(int(AS[j-1]) - c - j)\n if result_a >= result_c:\n a = b\n old_list.append(b)\n else:\n c = b\n old_list.append(b)\n b = (a+c) // 2\nresult = 0\nfor i in range (1, N+1):\n result += abs(int(AS[i-1]) - old_list[-1] - i)\nprint(result)', "import statistics\nimport math\nN = int(input())\nAS = input().split()\nAS = [int(i) for i in AS]\nBS = [int(AS[j-1] - j) for i in range(1,N+1)]\nb = int('{0:8.0f}'.format(statistics.median(BS)))\nresult_a = 0\nresult_b = 0\nresult_c = 0\nfor j in range (1, N+1):\n result_a += abs(int(AS[j-1]) - b - j)\nfor j in range (1, N+1):\n result_b += abs(int(AS[j-1]) - b - 1 - j)\nfor j in range (1, N+1):\n result_c += abs(int(AS[j-1]) - b + 1 - j)\nprint (int(min(result_a,result_b,result_c)))", "import statistics\nimport math\nN = int(input())\nAS = input().split()\nAS = [int(i) for i in AS]\nBS = [int(AS[j-1] - j) for i in range(1,N+1)]\nb = int('{0:8.0f}'.format(statistics.median(BS)))\nresult_a = 0\nresult_b = 0\nresult_c = 0\nfor j in range (1, N+1):\n result_a += abs(int(AS[j-1]) - b - j)\nfor j in range (1, N+1):\n result_b += abs(int(AS[j-1]) - b - 1 - j)\nfor j in range (1, N+1):\n result_c += abs(int(AS[j-1]) - b + 1 - j)\nprint (min(result_a,result_b,result_c))", 'N = int(input())\nAS = input().split()\nAS = [int(i) for i in AS]\nBS = [int(AS[j-1] - j) for j in range(1,N+1)]\nBS_s = BS.sort()\nb = BS[N//2]\nresult_a = 0\nresult_b = 0\nresult_c = 0\nfor j in range (1, N+1):\n result_a += abs(int(AS[j-1]) - b - j)\nfor j in range (1, N+1):\n result_b += abs(int(AS[j-1]) - b - 1 - j)\nfor j in range (1, N+1):\n result_c += abs(int(AS[j-1]) - b + 1 - j)\nprint (int(min(result_a,result_b,result_c)))'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s144280204', 's748774760', 's974963379', 's806516665'] | [20304.0, 27248.0, 27244.0, 26016.0] | [2105.0, 96.0, 93.0, 439.0] | [576, 483, 478, 432] |
p03309 | u284854859 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['1.\tn = int(input())\n2.\ta = list(map(int, input().split()))\n3.\ttmp = [a[x] - (x+1) for x in range(0,n)]\n4.\ttmp.sort()\n5.\tb = tmp[n // 2]\n6.\tprint(sum((abs(tmp[i] - b) for i in range(0,n))))\n', 'import copy\nN=int(input())\nli = list(map(int,input().split()))\nfor i in range(0,N):\n\tli[i] = li[i] - i -1\na = []\nd = copy.copy(li)\nwhile len(d) >= 3:\n\tdel d[max(d)]\n\tdel d[min(d)]\nfor i in range(min(d),max(d)+1):\n\tk = 0\n\tfor j in range(N):\n\t\tk = k + abs(li[j]-i)\n\ta.append(min(k))', 'import copy\nN=int(input())\nli = list(map(int,input().split()))\nfor i in range(0,N):\n\tli[i] = li[i] - i -1\na = []\nd = copy.copy(li)\nwhile len(d) >= 3:\n\tdel d[max(d)]\n\tdel d[min(d)]\nfor i in range(min(d),max(d)+1):\n\tk = 0\n\tfor j in range(N):\n\t\tk = k + abs(li[j]-i)\n\ta.append(k)\nprint(a)', 'n = int(input())\na = list(map(int,input().split()))\nfor i in range(n):\n a[i] -= i+1\na.sort()\nif n == 1:\n print(0)\n exit()\np = a[n//2]\nq = a[n//2 - 1]\nres = 0\nfor e in a:\n res += abs(e-p)\nans = 0\nfor e in a:\n ans += abs(e-q)\nprint(min(res,ans))\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s080443755', 's458545891', 's611857914', 's664017943'] | [2940.0, 26528.0, 27216.0, 25196.0] | [17.0, 120.0, 120.0, 256.0] | [189, 280, 284, 259] |
p03309 | u288948615 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nAn = list(map(int, input().split()))\n\nsum = 0\nfor n in range(N):\n sum += An[n] - (n+1)\n \na, b, c = sum//N -1, sum//N, sum//N + 1\n\nans = [0]*3\nfor n in range(N):\n ans[0] += abs(An[n] - (a+n+1))\n ans[0] += abs(An[n] - (b+n+1))\n ans[1] += abs(An[n] - (c+n+1))\n\nprint(min(ans))\n', 'N = int(input())\nAn = list(map(int, input().split()))\n\nfor n in range(N):\n An[n] -= (n+1)\n\nAn.sort()\n\nm = N-1\nif (m % 2 == 0):\n cent = (An[m/2] + An[m/2 + 1]) // 2\nelse:\n cent = An[(m+1)/2]\n\nans = 0\nfor n in range(N):\n ans += abs(An[n] - cent)\n\nprint(ans)\n\n', 'N = int(input())\nAn = list(map(int, input().split()))\n\nsum = 0\nfor n in range(N):\n sum += An[n] - (n+1)\n \na, b, c = sum//N, sum//N + 1\n\nans = [0]*3\nfor n in range(N):\n ans[0] += abs(An[n] - (a+n+1))\n ans[0] += abs(An[n] - (b+n+1))\n ans[1] += abs(An[n] - (c+n+1))\n\nprint(min(ans))\n', 'N = int(input())\nAn = list(map(int, input().split()))\n\nfor n in range(N):\n An[n] -= (n+1)\n\nAn.sort()\n\nif (N-1) % 2 != 0:\n m = N//2 - 1\nelse:\n m = (N-1)//2\n\nbf = -sum(An[0:m+1:]) + (m+1)*An[m]\naf = sum(An[m+1::]) - (N-m-1)*An[m]\nans = bf + af\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s334048806', 's404131304', 's575973126', 's248394767'] | [26180.0, 25744.0, 25748.0, 26020.0] | [296.0, 177.0, 112.0, 183.0] | [306, 269, 295, 261] |
p03309 | u299869545 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n a[i] -= i + 1\n\na.sort()\n\nb = a[n/2]\n\nfor i in range(n):\n a[i] = abs(a[i]-b)\nprint(sum(a))\n', 'n = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n a[i] -= i + 1\n\na.sort()\n\nb = a[n//2]\n\nfor i in range(n):\n a[i] = abs(a[i]-b)\nprint(sum(a))\n'] | ['Runtime Error', 'Accepted'] | ['s924381457', 's798143494'] | [26708.0, 26180.0] | [173.0, 229.0] | [169, 170] |
p03309 | u303037478 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import numpy as np\n\nn = int(input())\na_list = list(map(int, input().split()))\n\n\na_nparray=np.array(a_list)\ni_nparray=np.array(range(1,len(a_list)+1))\n\nbi_nparray=a_nparray-i_nparray\n\nb=np.median(bi_nparray)\n\nans=0\nfor i in range(len(a_list)):\n ans += abs(a_list[i]-(b+(i+1)))\n\nprint(ans)', 'import numpy as np\n\nn = int(input())\na_list = list(map(int, input().split()))\n\n\na_nparray=np.array(a_list)\ni_nparray=np.array(range(1,len(a_list)+1))\n\nbi_nparray=a_nparray-i_nparray\n\nb=int(np.median(bi_nparray))\n\nans=0\nfor i in range(len(a_list)):\n ans += abs(a_list[i]-(b+(i+1)))\n\nprint(ans)\n\n'] | ['Wrong Answer', 'Accepted'] | ['s585807930', 's388042531'] | [34164.0, 34192.0] | [1364.0, 1583.0] | [288, 295] |
p03309 | u306142032 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['def absnuke(a, b, n):\n sum = 0\n for i in range(n):\n sum += abs(a[i]-(b+i+1))\n return sum\n\nn = int(input())\na = list(map(int, input().split()))\n\nb = round(sum(a)/n)\nprint(b)\nprint(absnuke(a, 0, n))\n', 'def match_num(a, match):\n match_lst = []\n match = [j-len(match) for j in match]\n for k in range(len(match)*2):\n match_b = 0\n for i in range(len(match)):\n if a[i] == match[i]:\n match_b += 1\n match_lst.append(match_b)\n print(match) ##\n match = [j+1 for j in match]\n print(match_lst) ##\n return match_lst\n\ndef absnuke(a, b, n):\n sum = 0\n for i in range(n):\n sum += abs(a[i]-(b+i+1))\n return sum\n\nn = int(input())\na = list(map(int, input().split()))\n\n\nmatch = [x for x in range(1,n+1)]\n\nans = match_num(a, match)\n\nif max(ans)==1:\n b = 0\nelse:\n b = ans.index(max(ans))-len(match)\nprint(absnuke(a, b, n))\n', 'import numpy as np\ndef absnuke(a, b, n):\n sum = 0\n for i in range(n):\n sum += abs(a[i]-(b+i+1))\n return sum\n\nn = int(input())\na = list(map(int, input().split()))\n\nb = [a[i]-(i+1) for i in range(n)]\nc = sorted(b)\nx = int(np.median(c))\nprint(absnuke(a, x, n))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s108749711', 's297834960', 's995924403'] | [26708.0, 119608.0, 34184.0] | [104.0, 2106.0, 371.0] | [213, 697, 274] |
p03309 | u309108510 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['\nfrom statistics import median\n\n\nN = int(input())\nlistNumsAs = list(map(int,input().split()))\n\n\nlistNumsBs = []\n\n\nfor index in range(len(listNumsAs)):\n listNumsBs.append(listNumsAs[index] - index - 1)\n\n\nlistNumsBs.sort()\n\n\nmed = int(median(listNumsBs))\nprint("med: " + str(med))\n\nlistSadnessA1 = [abs(s - med - N) for s in listNumsBs]\nminimumSum = sum(listSadnessA1)\n\n\nfor b in range(med - N, med + N):\n \n \n listSadness = [abs(s - b) for s in listNumsBs]\n \n if sum(listSadness) < minimumSum:\n minimumSum = sum(listSadness)\n listTruthSadness = listSadness\n truthB = b\nprint(minimumSum)', '\nfrom statistics import median\n\n\nN = int(input())\nlistNumsAs = list(map(int,input().split()))\n\n\nlistNumsBs = []\n\n\nfor index in range(len(listNumsAs)):\n listNumsBs.append(listNumsAs[index] - index - 1)\n\n\nlistNumsBs.sort()\n\n\nmed = int(median(listNumsBs))\n\nlistSadnessA1 = [abs(s - med - N) for s in listNumsBs]\nminimumSum = sum(listSadnessA1)\n\n\nfor b in range(med - 10, med + 10):\n \n \n listSadness = [abs(s - b) for s in listNumsBs]\n \n if sum(listSadness) < minimumSum:\n minimumSum = sum(listSadness)\n listTruthSadness = listSadness\n truthB = b\n\nprint(minimumSum)'] | ['Wrong Answer', 'Accepted'] | ['s908084551', 's843580053'] | [46984.0, 52672.0] | [2108.0, 734.0] | [1114, 1091] |
p03309 | u310431893 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['def median(l):\n n = len(l)\n ls = sorted(l)\n if n == 1: return ls[0]\n if n%2 == 0:\n m1 = ls[int(n/2)-1]\n m2 = ls[int(n/2)]\n return (m1+m2)/2\n \n return ls[int(n/2)-1]\n\nN = int(input())\nA = [int(i) for i in input().split()]\n\nA_ = [A[i] - i - 1 for i in range(N)]\n\nA_m = median(A_)\nA_m1 = math.floor(A_m)\nA_m2 = math.ceil(A_m)\n\nA_b = [sum([abs(a - i) for a in A_]) for i in (A_m1, A_m2)]\n\nprint(min(A_b))', 'import math\n\ndef median(l):\n n = len(l)\n ls = sorted(l)\n if n%2 == 0:\n m1 = ls[int(n/2)-1]\n m2 = ls[int(n/2)]\n return (m1+m2)/2\n \n return ls[int(n/2)]\n\nN = int(input())\nA = [int(i) for i in input().split()]\n\nA_ = [A[i] - i - 1 for i in range(N)]\n\nA_m = median(A_)\nA_m1 = math.floor(A_m)\nA_m2 = math.ceil(A_m)\n\nA_b = [sum([abs(a - i) for a in A_]) for i in (A_m1, A_m2)]\n\nprint(min(A_b))'] | ['Runtime Error', 'Accepted'] | ['s759182985', 's160301266'] | [25836.0, 28272.0] | [182.0, 214.0] | [439, 422] |
p03309 | u318029285 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int, input().split()))\nB = [A[i] - (i+1) for i in range(len(A))]\nB.sort()\n\nif N % 2 != 0:\n b = B[(N+1)//2 - 1]\n print(b)\n ans = 0\n for i in range(len(B)):\n ans += abs(B[i] - b)\nelse:\n b1 = B[N//2 - 1]\n ans1 = 0\n for i in range(len(B)):\n ans1 += abs(B[i] - b1)\n b2 = B[N//2]\n ans2 = 0\n for i in range(len(B)):\n ans2 += abs(B[i] - b2)\n ans = min(ans1, ans2)\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nB = [A[i] - (i+1) for i in range(len(A))]\nB.sort()\n\nif N % 2 != 0:\n b = B[(N+1)//2 - 1]\n ans = 0\n for i in range(len(B)):\n ans += abs(B[i] - b)\nelse:\n b1 = B[N//2 - 1]\n ans1 = 0\n for i in range(len(B)):\n ans1 += abs(B[i] - b1)\n b2 = B[N//2]\n ans2 = 0\n for i in range(len(B)):\n ans2 += abs(B[i] - b2)\n ans = min(ans1, ans2)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s622757460', 's199574230'] | [26020.0, 25744.0] | [267.0, 253.0] | [450, 438] |
p03309 | u329709276 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import numpy as np\nfrom scipy.optimize import minimize\nN = int(input())\nA = list(map(int,input().split()))\n\ndef func(x):\n return sum([abs(v - (x + i + 1)) for i,v in enumerate(A)])\n\ndef cons(x):\n return -10^9 <= x <= 10^9\n\ncons = (\n {\n \'type\': \'ineq\', \'fun\': cons\n }\n)\nresult = minimize(func,x0=-10^9,constraints=cons,method="SLSQP")\nprint(int(np.round(result[\'fun\'])))', 'N = int(input())\nA = list(map(int,input().split()))\nL = sorted([v - (i+1) for i,v in enumerate(A)])\nans = 0\nfor i in range(N):\n ans += abs(A[i] - (L[N//2] + i+1))\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s930601859', 's696135352'] | [57384.0, 26228.0] | [2114.0, 252.0] | [388, 177] |
p03309 | u337851472 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import math\nimport statistics\n\n\nN = int(input())\nA = [int(i) for i in input().split()]\nb = math.ceil(statistics.median([a-n for a,n in zip(A,range(1,N+1))]))\nprint(b)\nans = [abs(a - b - n) for a,n in zip(A,range(1, N+1))]\nprint(sum(ans))\n', 'import math\nimport statistics\n\n\nN = int(input())\nA = [int(i) for i in input().split()]\nb = math.ceil(statistics.median([a-n for a,n in zip(A,range(1,N+1))]))\nans = [abs(a - b - n) for a,n in zip(A,range(1, N+1))]\nprint(sum(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s157439403', 's422743968'] | [27236.0, 27204.0] | [223.0, 252.0] | [238, 229] |
p03309 | u346308892 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['\nimport numpy as np\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\n\ndef serch(x, count):\n #print("top", x, count)\n \n\n for d in directions:\n nx = d+x\n #print(nx)\n if np.all(0 <= nx) and np.all(nx < (H, W)):\n if field[nx[0]][nx[1]] == "E":\n count += 1 \n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n continue\n if field[nx[0]][nx[1]] == "#":\n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n \n return count\n\nN=int(input())\nA=np.array(acinput())\ns=A-range(1,N+1)\n\ns=sorted(s)\nm=np.median(s)\n\nres=0\nfor i in range(N):\n res+=np.abs(A[i]-m-(i+1))\n\nprint(res)\n\n', '\nimport numpy as np\nimport sys\nsys.setrecursionlimit(100000)\n\n\n\ndef acinput():\n return list(map(int, input().split(" ")))\n\n\n\ndirections=np.array([[1,0],[0,1],[-1,0],[0,-1]])\ndirections = list(map(np.array, directions))\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\n\ndef serch(x, count):\n #print("top", x, count)\n \n\n for d in directions:\n nx = d+x\n #print(nx)\n if np.all(0 <= nx) and np.all(nx < (H, W)):\n if field[nx[0]][nx[1]] == "E":\n count += 1 \n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n continue\n if field[nx[0]][nx[1]] == "#":\n field[nx[0]][nx[1]] = "V"\n count = serch(nx, count) \n \n return count\n\nN=int(input())\nA=np.array(acinput())\ns=A-range(1,N+1)\n\ns=sorted(s)\nm=round(np.median(s))\n\nres=0\nfor i in range(N):\n res+=np.abs(A[i]-m-(i+1))\n\nprint(int(res))\n'] | ['Wrong Answer', 'Accepted'] | ['s597173020', 's360938714'] | [34184.0, 34188.0] | [1922.0, 1974.0] | [1023, 1034] |
p03309 | u351568944 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int, input().split()))\nA_ = [a-i-1 for i,a in enumerate(A)]\nprint (A_)\nA_.sort()\nprint (A_)\nb = A_[N//2]\nprint (b)\nprint(sum([abs(ai-b) for ai in A_]))', '5\n2 2 3 5 5', 'N = int(input())\nA = list(map(int, input().split()))\nA_ = [a-i-1 for i,a in enumerate(A)]\n\nA_.sort()\n\nb = A_[N//2]\n\nprint(sum([abs(ai-b) for ai in A_]))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s639189205', 's914860410', 's910828959'] | [31828.0, 2940.0, 26820.0] | [245.0, 17.0, 193.0] | [181, 11, 152] |
p03309 | u357810840 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n = int(input())\nlist = input().split()\n\nfor i in range(n):\n list[i] = int(list[i]) - (i + 1)\n\nb = int(median(list))\n\nfor i in range(n):\n list[i] = abs(list[i] - b)\n\nprint(sum(list))\n\n', 'from statistics import *\n\n\n\nn = int(input())\nlist = input().split()\n\nfor i in range(n):\n list[i] = int(list[i]) - (i + 1)\n\nb = int(median(list))\n\nfor i in range(n):\n list[i] = abs(list[i] - b)\n\nprint(sum(list))\n\n'] | ['Runtime Error', 'Accepted'] | ['s895881288', 's052326025'] | [19216.0, 21680.0] | [119.0, 245.0] | [190, 218] |
p03309 | u362560965 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from statistics import median\nN = int(input())\nA = [int(i) for i in input().split()]\n\nB = [A[i] - (i+1) for i in range(N)]\nb = int(median(B))\n\nC = [abs(B[i] - b) for i in range(N)]\n\nprint(C)\n', 'from statistics import median\nN = int(input())\nA = [int(i) for i in input().split()]\n\nB = [A[i] - (i+1) for i in range(N)]\nb = int(median(B))\n\nC = [abs(B[i] - b) for i in range(N)]\n\nprint(sum(C))\n'] | ['Wrong Answer', 'Accepted'] | ['s099233395', 's271483291'] | [35256.0, 29696.0] | [242.0, 225.0] | [191, 196] |
p03309 | u366644013 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from collections import counter\nn = int(input())\na = [int(i) for i in input().split()]\noutput = 0\nb = [abs(elem - i) for i, elem in enumerate(a, 1)]\nc = counter(b)\nd = c.most_common()\n\nsurume = 0\nif len(d) == 1:\n surume = d[0][0]\nelse:\n if d[0][1] == d[1][1]:\n surume = 0\n else:\n surume = d[0][0]\ne = [abs(abs(elem - i) - abs(surume)) for i, elem in enumerate(a, 1)]\nprint(sum(e))', 'import math\n\nn = int(input())\na = [int(i) for i in input().split()]\nb = [elem - i for i, elem in enumerate(a, 1)]\nb.sort()\ncenter = b[math.floor(len(b) / 2)]\nc = [abs(i - center) for i in b]\nprint(sum(c))'] | ['Runtime Error', 'Accepted'] | ['s071970197', 's983239064'] | [3316.0, 27756.0] | [21.0, 198.0] | [403, 204] |
p03309 | u366964431 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ["import numpy as np\n\nN = int(input())\ntmp = input().split(' ')\n\nA = []\nfor i in range(N):\n A.append(int(tmp[i]))\n\nA = np.asarray(A)\n\nz = np.asarray([x for x in range(N)])\nA = A - z\n\nb = np.round(np.median(A)).astype(np.uint32)\nprint(b)\nA = A - b\nA = np.absolute(A)\nprint(A.sum().astype(np.uint32))", "import numpy as np\n\nN = int(input())\ntmp = input().split(' ')\n\nA = []\nfor i in range(N):\n A.append(int(tmp[i]))\n\nA = np.asarray(A)\n\nz = np.asarray([x for x in range(N)])\nA = A - z\n\nb = np.round(np.median(A)).astype(np.int32)\nprint(b)\nA = A - b\nA = np.absolute(A)\nprint(A.sum().astype(np.uint32))", "import numpy as np\n\nN = int(input().strip())\nA = list(map(int, input().strip().split(' ')))\n\nA = np.asarray(A)\ni = np.asarray([x for x in range(1, N+1)])\nA = A - i\n\n#b = np.round(np.median(A))\nb = np.ceil(np.median(A))\nA = A - b\nA = np.absolute(A)\nprint(A.sum().astype(np.uint64))"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s319294812', 's787863198', 's381204347'] | [37320.0, 37304.0, 34184.0] | [271.0, 294.0, 235.0] | [299, 298, 280] |
p03309 | u380793800 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import numpy as np\n\nn = int(input())\na = list(map(int, input().split()))\nb = [0] * n\n\ns1 = 0\ns2 = 0\ns3 = 0\n\nfor i in range(n):\n b[i] = a[i] - i\n\nb1 = np.median(b)//n\nb2 = np.median(b)//n + 1\nb3 = np.median(b)//n - 1\n\nfor i in range(n):\n s1 += abs(a[i] - b1 - i)\n\nfor i in range(n):\n s2 += abs(a[i] - b2 - i)\n\nfor i in range(n):\n s3 += abs(a[i] - b3 - i)\n\nprint(min(s1, s2, s3))\n', 'n = int(input())\na = list(map(int, input().split()))\nb = [0] * n\n\ns1 = 0\ns2 = 0\n\nfor i in range(n):\n b[i] = a[i] - i\nb.sort()\n\nb1 = b[n//2]\nb2 = b[n//2-1]\n\nfor i in range(n):\n s1 += abs(a[i] - b1 - i)\n\nfor i in range(n):\n s2 += abs(a[i] - b2 - i)\n\nprint(min(s1, s2))\n'] | ['Wrong Answer', 'Accepted'] | ['s028347036', 's982998983'] | [34988.0, 25200.0] | [1798.0, 303.0] | [390, 276] |
p03309 | u382423941 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ["n = int(input())\nA = [int(_) for _ in input().split()]\nB = [a - i for i, a in enumerate(A)]\n\nidx = n // 2\nans = sum([abs(b - B[idx]) for b in B])\nprint(ans)\nif n % 2 == 0:\n idx = n // 2\n ans = min(ans, sum([abs(b - B[idx]) for b in B]))\nprint('{:.0f}'.format(ans))\n", 'n = int(input())\nA = [int(_) for _ in input().split()]\nB = sorted([a - i - 1 for i, a in enumerate(A)])\nans = sum([abs(b - B[n//2]) for b in B])\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s284316540', 's879087169'] | [26948.0, 27532.0] | [142.0, 223.0] | [271, 156] |
p03309 | u386131832 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n = int(input())\na = list(map(int,input().split()))\nb = [x-i-1 for x,i in zip(a,range(n))]\nans = sum([abs(x) for x in b])\nngo = 0\nval = 0\nfor i in list(set(b)):\n tmp = abs(b.count(i)*i)\n if ngo < tmp:\n ngo = tmp\n val = i\nprint(sum([abs(x-val) for x in b]))', 'n = int(input())\na = list(map(int,input().split()))\nb = sorted([x-i-1 for x,i in zip(a,range(n))])\nprint(sum([abs(x-b[n//2]) for x in b]))'] | ['Wrong Answer', 'Accepted'] | ['s962004622', 's339367301'] | [34084.0, 27536.0] | [2105.0, 207.0] | [276, 138] |
p03309 | u391066416 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['def absFunc(A_, b):\n result = 0\n for a_ in A_:\n result += abs(a_ - b)\n return result\n \ninput()\nA = list(map(int, input().split()))\nA_ = []\n\nfor i, a in enumerate(A):\n A_.append(a - i - 1)\n\nb = 0\nresult_o = absFunc(A_, b)\nresult_n = 0\n\nwhile True:\n b += 1\n result_n = absFunc(A_, b)\n print(result_o,result_n)\n \n if result_n < result_o:\n result_o = result_n\n continue\n break\n\nb = 0\nwhile True:\n b -= 1\n result_n = absFunc(A_, b)\n print(result_o,result_n)\n \n if result_n < result_o:\n result_o = result_n\n continue\n break\n\nprint(result_o)\n', 'N = int(input())\nA = list(map(int, input().split()))\nA_ = []\nresult = 0\n\nfor i, a in enumerate(A):\n A_.append(a - i - 1)\n\nb = sorted(A_)[N//2]\n\nfor a_ in A_:\n result += abs(a_ - b)\n\nprint(result)\n'] | ['Wrong Answer', 'Accepted'] | ['s320941057', 's401300079'] | [25904.0, 26180.0] | [2105.0, 219.0] | [621, 202] |
p03309 | u391731808 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int,input().split()))\nb = sorted([b-i for i,b in enumerate(A,1)])\n\nminus = 0\nplus = 0\nfor i,c in enumerate(b,1):\n if c <0:\n minus +=1\n elif c >0:\n plus +=1\n\nm = b[(N-minus+plus)//2]\nout = sum([abs(c-m) for c in b])\nprint(out)', 'N = int(input())\nA = list(map(int,input().split()))\nb = sorted([a-i for i,a in enumerate(A,1)])\n\nminus = 0\nplus = 0\nfor c in b:\n if c <0:\n minus +=1\n elif c >0:\n plus +=1\n\nm1 = b[N//2]\nm2 = b[0] if N==1 else b[N//2+1]\nout = min(sum([abs(c-m1) for c in b]),sum([abs(c-m2) for c in b]))\nprint(out)'] | ['Runtime Error', 'Accepted'] | ['s600074971', 's518809495'] | [27844.0, 27716.0] | [236.0, 275.0] | [275, 315] |
p03309 | u393693918 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int, input().split()))\nB = []\n\nfor i in range(N):\n B.append(A[i] - i)\n\nB = sorted(B)\nM = B[int((N + 1)/2)]\nans = 0\n\nfor i in range(N):\n t = B[i] - M\n if t < 0:\n t = (-1) * t\n ans += t\n\nprint(ans)', 'N = int(input())\nA = sorted(list(map(int, input().split())))\nM = int((N + 1)/2)\nans = 0\n\nfor i in range(N):\n t = A[i] - A[M]\n if t < 0:\n t = (-1) * t\n ans += t\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\nB = []\n\nfor i in range (N):\n B[i] = A[i]- i\n\nB = sorted(B)\nM = B[int((N + 1)/2)]\nans = 0\n\nfor i in range(N):\n t = B[i] - M\n if t < 0:\n t = (-1) * t\n ans += t\n\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nB = []\n\nfor i in range(N):\n B.append(A[i] - i - 1)\n\nB = sorted(B)\nM = B[int((N + 1)/2)]\nans = 0\n\nfor i in range(N):\n t = B[i] - M\n if t < 0:\n t = (-1) * t\n ans += t\n\nprint(ans)\n', 'N = int(input())\nA = list(map(int, input().split()))\nB = []\n\nfor i in range(N):\n B.append(A[i] - i - 1)\n\nB = sorted(B)\nM = B[int((N - 1)/2)]\nans = 0\n\nfor i in range(N):\n t = B[i] - M\n if t < 0:\n t = (-1) * t\n ans += t\n\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s092345913', 's125380315', 's694417399', 's772267834', 's983039884'] | [26180.0, 26708.0, 25196.0, 26836.0, 25200.0] | [254.0, 227.0, 69.0, 250.0, 281.0] | [244, 188, 241, 249, 249] |
p03309 | u395816772 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ["import numpy as np\nn = int(input())\na = [int(i)- k-1 for k,i in enumerate(input().split())]\nans = 10**9\na = np.array(a,dtype = 'int64')\nsum_a = np.sum(a)\nvar= np.round(sum_a / n)\nfor i in range(10**4+1):\n c = a -i + var\n e = a + i + var\n ans = min(ans, min(np.sum(np.abs(c)),np.sum(np.abs(e))))\nprint(ans)", "import numpy as np\nn = int(input())\na = [int(i)- k-1 for k,i in enumerate(input().split())]\nans = 10**9\na = np.array(a,dtype = 'int64')\nmedian = int(np.median(a))\n\nprint(np.sum(np.abs(a-median)))"] | ['Wrong Answer', 'Accepted'] | ['s017681657', 's553574306'] | [49444.0, 49288.0] | [2207.0, 181.0] | [314, 195] |
p03309 | u410269178 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import numpy as np\nn = int(input())\na = np.array(list(map(int, input().split())))\nb = a - np.arange(1, n+1)\nprint(int(np.median(b)))', 'import numpy as np\nn = int(input())\na = np.array(list(map(int, input().split()))) - np.arange(1, n+1)\nb = int(np.median(a))\nprint(int(np.sum(np.abs(a - b))))'] | ['Wrong Answer', 'Accepted'] | ['s940957469', 's979001751'] | [34180.0, 34180.0] | [214.0, 213.0] | [132, 157] |
p03309 | u416011173 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['# -*- coding: utf-8 -*-\n\nimport itertools\n\n\ndef get_input() -> tuple:\n \n N = int(input())\n A = list(map(int, input().split()))\n\n return N, A\n\n\ndef main(A: list) -> None:\n \n \n ans = 0\n for A_i, A_j in itertools.combinations(A, r=2):\n ans = max(ans, abs(A_i - A_j))\n\n \n print(ans)\n\n\nif __name__ == "__main__":\n \n N, A = get_input()\n\n \n main(A)\n', '# -*- coding: utf-8 -*-\n\nimport statistics\n\n\ndef get_input() -> tuple:\n \n N = int(input())\n A = list(map(int, input().split()))\n\n return N, A\n\n\ndef main(N: int, A: list) -> None:\n \n \n B = [A[i] - (i + 1) for i in range(N)]\n b = statistics.median_high(B)\n ans = sum([abs(B[i] - b) for i in range(N)])\n\n \n print(ans)\n\n\nif __name__ == "__main__":\n \n N, A = get_input()\n\n \n main(N, A)\n'] | ['Wrong Answer', 'Accepted'] | ['s590154748', 's510282714'] | [31168.0, 35416.0] | [2206.0, 163.0] | [673, 765] |
p03309 | u417658545 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['def FindAns(A, b):\n ans = 0\n for a in A:\n ans += abs(a - b)\n return ans\n\nn = int(input())\nA = list(map(int, input().split()))\nfor i in range(n):\n A[i] -= i + 1\n\ncenter = int(sum(A) / len(A))\nans = 100000000000000\nfor i in range(21):\n ans = min(ans, FindAns(center - 50))\nprint(ans)', 'def BinSearch(A, hi, lo):\n b = (hi + lo) // 2\n tmp0 = FindAns(A, b - 1)\n tmp1 = FindAns(A, b)\n if hi == lo:\n tmp2 = FindAns(A, b + 1)\n return min(tmp0, tmp1, tmp2)\n if tmp0 < tmp1:\n return BinSearch(A, b - 1, lo)\n else:\n return BinSearch(A, hi, b + 1)\n \ndef FindAns(A, b):\n ans = 0\n for a in A:\n ans += abs(a - b)\n return ans\n\nn = int(input())\nA = list(map(int, input().split()))\nfor i in range(n):\n A[i] -= i + 1\n \nhi = max(A)\nlo = min(A)\n\nprint(BinSearch(A, hi, lo))\n'] | ['Runtime Error', 'Accepted'] | ['s359143162', 's687683330'] | [25196.0, 25708.0] | [107.0, 1425.0] | [303, 540] |
p03309 | u426764965 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['\ndef abc102_c():\n N = int(readline())\n A = np.array(read().split(), dtype=np.int64)\n\n \n B = A - np.arange(1, N+1)\n \n B.sort()\n x = B[N//2]\n \n ans = np.abs(B - x).sum()\n print(ans)\n\nabc102_c()', '\n\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nimport numpy as np\n\ndef abc102_c():\n N = int(readline())\n A = np.array(read().split(), dtype=np.int64)\n\n \n B = A - np.arange(1, N+1)\n \n B.sort()\n x = B[N//2]\n \n ans = np.abs(B - x).sum()\n print(ans)\n\nabc102_c()'] | ['Runtime Error', 'Accepted'] | ['s647447680', 's579394005'] | [3060.0, 25072.0] | [17.0, 299.0] | [380, 518] |
p03309 | u430726059 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n=int(input())\nalist=list(map(int, input().split()))\nblist=[]\nfor i in range(n):\n blist.append(alist[i]-i-1)\nblist.sort()\nif n%2==1:\n cnt=0\n for i in range(n):\n cnt+=abs(blist[i]-blist[(i+1)//2])\n print(cnt)\nelse:\n cnt=0\n num=(blist[i//2]+blist[i//2+1])//2\n for i in range(n):\n cnt+=abs(blist[i]-num\n print(cnt,cnt2)', 'import statistics\nn=int(input())\nalist=list(map(int, input().split()))\nblist=[]\nfor i in range(n):\n blist.append(alist[i]-i-1)\nblist.sort()\nmedian=statistics.median_high(blist)\nans=0\nfor i in range(n):\n ans+=abs(blist[i]-median)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s467296353', 's019339988'] | [9036.0, 33860.0] | [29.0, 187.0] | [330, 241] |
p03309 | u437215432 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['n = int(input())\na = [int(x) for x in input().split()]\n\na2 = [a[i] - i - 1 for i in range(n)]\nmean = sum(a2) / len(a2)\nb = np.floor(mean)\na3 = sum([abs(a2[i] - b) for i in range(n)])\nb = np.ceil(mean)\na4 = sum([abs(a2[i] - b) for i in range(n)])\nprint(int(min(a3, a4)))\n', 'import numpy as np\n\nn = int(input())\na = [int(x) for x in input().split()]\n\na2 = [a[i] - i - 1 for i in range(n)]\nmean = sum(a2) / len(a2)\nmedian = np.median(np.array(a2))\nb = np.floor(median)\na3 = sum([abs(a2[i] - b) for i in range(n)])\nb = np.ceil(median)\na4 = sum([abs(a2[i] - b) for i in range(n)])\nprint(int(min(a3, a4)))\n'] | ['Runtime Error', 'Accepted'] | ['s162509313', 's733288471'] | [26176.0, 35792.0] | [98.0, 816.0] | [270, 327] |
p03309 | u451017206 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from statistics import median\nN = int(input())\nA = [int(i) for i in input().split()]\n\ndef k(A, b):\n return sum([abs(a - (b+i+1)) for i,a in enumerate(A)])\n\n\na = [a - i+1 for i,a in enumerate(A)]\nb = median(a)\n\nprint(k(A,b))', "from numpy import cumsum\nfrom bisect import bisect\nN = int(input())\nA = [int(i) for i in input().split()]\nX = [v - i - 1 for i, v in enumerate(A)]\nX.sort()\nS = cumsum(X)\nans = float('inf')\nfor bc in set(X):\n i = bisect(X, bc)\n a = -1 * S[i - 1] + bc * i + (S[N - 1] - S[i - 1]) + -1 * bc * (N - i)\n ans = min(ans, a)\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s566715518', 's063244479'] | [28088.0, 43284.0] | [273.0, 1428.0] | [226, 336] |
p03309 | u455233471 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = [int(i) for i in input().split()]\n\ndef calc_sadness(points, b):\n return sum([abs(y - (b + x)) for x, y in points])\n\n\n\nb_list = [y - x for x, y in points]\nb_list.sort(reverse=True)\n\n\nmax_b = b_list[0]\nmin_b = b_list[-1]\n\n\ndef search(max_b, min_b):\n\n eval_max = eval_sadness(points, max_b)\n eval_min = eval_sadness(points, min_b)\n \n if max_b == min_b + 1: # neighbors\n return min(eval_max, eval_min)\n \n mid_b = (max_b + min_b) // 2\n eval_mid = eval_sadness(points, mid_b)\n\n minimum = min(eval_max, eval_mid, eval_min)\n #print(eval_mid)\n\n if minimum == eval_max:\n return eval_max\n elif minimum == eval_min:\n return eval_min\n else:\n return min(search(max_b, mid_b), search(mid_b, min_b))\n\nif max_b == min_b:\n print(calc_sadness(points, min_b))\nelse:\n print(search(max_b, min_b))', 'N = int(input())\nA = [int(i) for i in input().split()]\ndef calc_sadness(points, b):\n return sum([abs(y - (b + x)) for x, y in points])\n\npoints = [(i+1, y) for i, y in enumerate(A)]\n\n\n\nb_list = [y - x for x, y in points]\nb_list.sort(reverse=True)\n\nmax_b = b_list[0]\nmin_b = b_list[-1]\n\nbest_ind = len(b_list)//2\n\nminimum = calc_sadness(points, b_list[best_ind])\n\nprint(minimum)'] | ['Runtime Error', 'Accepted'] | ['s404779680', 's463340500'] | [26016.0, 47424.0] | [75.0, 248.0] | [894, 401] |
p03309 | u455696302 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = [int(i) for i in input().split()]\n \nsub = [A[i]-(i+1) for i in range(N)]\nres = 0\n\nif N % 2 != 0:\n b = sub[int(N-1/2)+1]\n res = 0\n for i in range(N):\n res += abs(A[i]-(b+i+1))\nelse:\n b1 = sub[int(N-1/2)]\n b2 = sub[int(N-1/2)+1]\n res1 = 0\n for i in range(N):\n res1 += abs(A[i]-(b1+i+1))\n res2 = 0\n for i in range(N):\n res2 += abs(A[i]-(b2+i+1))\n res = min(res1,res2)\n\nprint(res)', 'N = int(input())\nA = [int(i) for i in input().split()]\n \nsub = [A[i]-(i+1) for i in range(N)]\nres = 0\n\nif N % 2 != 0:\n b = sub[int(N/2)+1]\n res = 0\n for i in range(N):\n res += abs(A[i]-(b+i+1))\nelse:\n b1 = sub[int(N/2)]\n b2 = sub[int(N/2)+1]\n res1 = 0\n for i in range(N):\n res1 += abs(A[i]-(b1+i+1))\n res2 = 0\n for i in range(N):\n res2 += abs(A[i]-(b2+i+1))\n res = min(res1,res2)\n\nprint(res)', 'import collections\n \nN = int(input())\nA = [int(i) for i in input().split()]\n \nsub = [A[i]-(i+1) for i in range(N)]\nres = 0\n\nif N % 2 != 0:\n b = sub[int(N/2)+1]\n res = 0\n for i in range(N):\n res += abs(A[i]-(b+i+1))\nelse:\n b1 = sub[int(N/2)]\n b2 = sub[int(N/2)+1]\n res1 = 0\n for i in range(N):\n res1 += abs(A[i]-(b1+i+1))\n res2 = 0\n for i in range(N):\n res2 += abs(A[i]-(b2+i+1))\n res = min(res1,res2)\n\nprint(res)', 'import collections\n \nN = int(input())\nA = [int(i) for i in input().split()]\n \nsub = [A[i]-(i+1) for i in range(N)]\nres = 0\nsub = sorted(sub)\nb = sub[int(N/2)]\n \nres = 0\nfor i in range(N):\n res += abs(A[i]-(b+i+1))\n \nprint(res)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s037109628', 's320263758', 's883919435', 's310468939'] | [26016.0, 25836.0, 26764.0, 26764.0] | [99.0, 224.0, 242.0, 245.0] | [448, 442, 463, 229] |
p03309 | u466335531 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N=int(input())\nA=list(map(int, input().split()))\n\nans=9999999999\nn=min(min(A),max(A)-N)\nfor b in range(n,max(A)):\n num=0\n for i,a in enumerate(A):\n num += abs(a-(b+i+1))\n if num<ans: \n ans=num\n print(b)\nprint(ans)', 'N=int(input())\nA=list(map(int,input().split()))\nB=[]\nfor i in range(N):\n B.append(A[i]-i-1)\nB.sort()\nif N%2:\n b=B[N//2]\nelse:\n b=(B[N//2]+B[N//2-1])//2\nans=0\nfor k in B:\n ans+=abs(k-b)\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s976103140', 's083367920'] | [25200.0, 26360.0] | [2104.0, 225.0] | [243, 207] |
p03309 | u471214054 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int, input().split()))\nAd = [A[i]-(i+1) for i in range(N)]\nmax_Ad = max(abs(Ad))\nmin_total = float("inf")\n\nfor b in range(0, max_Ad+1):\n map(lambda x: x-b, Ad)\n total = sum(abs(Ad))\n if min_total > total:\n min_total = total\nprint(min_total)\n', 'N = int(input())\nA = list(map(int, input().split()))\nAd = [A[i]-(i+1) for i in range(N)]\nmax_Ad = max(abs(Ad))\nmin_total = float("inf")\n\nfor b in range(0, max_Ad+1):\n map(lambda x: x-b, Ad)\n total = sum(abs(Ad))\n if min_total > total:\n min_total = total\nprint(min_total)\n', 'N = int(input())\nA = list(map(int, input().split()))\nAd = [A[i]-(i+1) for i in range(N)]\nmax_Ad = max(abs(Ad))\nmin_total = float("inf")\n\nfor b in range(0, max_Ad+1):\n map(lambda x: x-b, Ad)\n total = sum(abs(Ad))\n if min_total > total:\n min_total = total\nprint(min_total)\n', 'N = int(input())\nA = list(map(int, input().split()))\nAd = [A[i]-(i+1) for i in range(N)]\nmax_Ad = max(abs(Ad))\nmin_total = float("inf")\n\nfor b in range(0, max_Ad+1):\n map(lambda x: x-b, Ad)\n total = sum(abs(Ad))\n if min_total > total:\n min_total = total\nprint(min_total)\n', 'N = int(input())\nA = list(map(int, input().split()))\nAd = [A[i]-(i+1) for i in range(N)]\nmax_Ad = max(abs(Ad))\nmin_total = float("inf")\n\nfor b in range(0, max_Ad+1):\n map(lambda x: x-b, Ad)\n total = sum(abs(Ad))\n if min_total > total:\n min_total = total\nprint(min_total)\n', 'N = int(input())\nA = list(map(int, input().split()))\nAd = [A[i]-(i+1) for i in range(N)]\nAd.sort()\nl = len(Ad)\nif l % 2 == 1:\n b = Ad[l//2]\n ans = sum(map(lambda x:abs(x-b), Ad))\nelse:\n b1, b2 = Ad[l//2], Ad[l//2-1]\n ans = min(sum(map(lambda x:abs(x-b1), Ad)), sum(map(lambda x:abs(x-b2), Ad)))\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s305834006', 's335899867', 's384070662', 's663723126', 's736192857', 's088589686'] | [26708.0, 26836.0, 26360.0, 26708.0, 26020.0, 26016.0] | [100.0, 96.0, 92.0, 91.0, 100.0, 233.0] | [287, 287, 287, 287, 287, 318] |
p03309 | u474270503 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['from collections import Counter\nN=int(input())\nA = list(map(int,input().split()))\n\nfor i in range(1,N+1):\n A[i-1]-=i\n\nave1=sum(A)//len(A)\nave2=-(-sum(A)//len(A))\nmedian=Counter(A).most_common(1)[0][0]\nprint(median)\nB=A[:]\nC=A[:]\nfor i in range(0,N):\n A[i]-=ave1\n B[i]-=ave2\n C[i]-=median\n A[i]=abs(A[i])\n B[i]=abs(B[i])\n C[i]=abs(C[i])\nprint(min(sum(A),sum(B),sum(C)))\n', 'from collections import Counter\nN=int(input())\nA = list(map(int,input().split()))\n\nfor i in range(1,N+1):\n A[i-1]-=i\n\n\n\n# median=Counter(A).most_common(1)[0][0]\n\nB=A[:]\nC=A[:]\n\nB.sort()\n\nif N % 2 == 0:\n median1 = N/2\n median2 = N/2 + 1\n median1 = int(median1) - 1\n median2 = int(median2) - 1\n median = (B[median1] + B[median2]) / 2\n\n \nelse:\n median = (N + 1) / 2\n median = int(median) - 1\n median = B[median]\n\nmedian=int(median)\n\nfor i in range(0,N):\n C[i]-=median\n C[i]=abs(C[i])\n\nprint(sum(C))\n'] | ['Wrong Answer', 'Accepted'] | ['s823871466', 's366730084'] | [33640.0, 26764.0] | [322.0, 249.0] | [390, 612] |
p03309 | u475503988 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\nb = np.median((A - np.arange(1, N+1)))\nans = np.inf\nfor i in [b-1, b, b+1]:\n ans = min(np.abs(A - i - np.arange(1, N+1)).sum(), ans)\n\nprint(ans)\n', 'import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\nb = np.median((A - np.arange(1, N+1)))\nans = np.abs(A - b - np.arange(1, N+1)).sum()\n\nprint(int(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s096932440', 's520386727'] | [34188.0, 34176.0] | [221.0, 214.0] | [231, 185] |
p03309 | u492532572 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA_list = list(map(int, input().split()))\nmin_sum = 0\nfor b in range(len(A_list)):\n sum = 0\n for i, a in enumerate(A_list):\n sum += abs(a - (b + i))\n min_sum = min(min_sum, sum)\nprint(min_sum)', 'N = int(input())\nA_list = list(map(int, input().split()))\nB_list = [a - (i + 1) for i, a in enumerate(A_list)]\nB_list.sort()\nb = B_list[int(len(B_list) / 2)]\ns = sum([abs(B - b) for B in B_list])\nprint(s)'] | ['Wrong Answer', 'Accepted'] | ['s891174135', 's018294002'] | [26708.0, 26860.0] | [2104.0, 195.0] | [224, 204] |
p03309 | u497625442 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int,input().split()))\nC = [A[i] - (i+1) for i in range(N)]\n\ndef SAD(C,b):\n\tS = 0\n\tfor i in range(N):\n\t\tS += abs(C[i] - b)\n\treturn S\n\nMAX, MIN = max(C), min(C)\n\ni = 0\nwhile MIN != MAX:\n\tx1 = (MIN*2+MAX)//3\n\tx2 = (MIN+MAX*2)//3\n\ts1 = SAD(C,x1)\n\ts2 = SAD(C,x2)\n\tif x2 - x1 == 1:\n\t\tprint(min(s1,s2))\n\t\texit()\n\tif s1 > s2:\n\t\tMIN = x1\n\telse:\n\t\tMAX = x2\n', 'import itertools, math\nN = int(input())\nA = list(map(int,input().split()))\nC = [A[i] - (i+1) for i in range(N)]\n\ndef SAD(C,b):\n\tS = 0\n\tfor i in range(N):\n\t\tS += abs(C[i] - b)\n\treturn S\n\nMAX, MIN = max(C)+1, min(C)\n\ni = 0\nwhile MAX - MIN > 1:\n\tmid = (MIN + MAX)//2\n#\tprint((MIN,mid,MAX,":",SAD(C,mid) - SAD(C,mid-1)))\n\tif \tSAD(C,mid) - SAD(C,mid-1) < 0:\n\t\tMIN = mid\n\telse:\n\t\tMAX =mid\nprint(SAD(C,MIN))\n'] | ['Wrong Answer', 'Accepted'] | ['s135916264', 's481578119'] | [27712.0, 26096.0] | [2105.0, 1700.0] | [377, 401] |
p03309 | u497952650 | 2,000 | 1,048,576 | Snuke has an integer sequence A of length N. He will freely choose an integer b. Here, he will get sad if A_i and b+i are far from each other. More specifically, the _sadness_ of Snuke is calculated as follows: * abs(A_1 - (b+1)) + abs(A_2 - (b+2)) + ... + abs(A_N - (b+N)) Here, abs(x) is a function that returns the absolute value of x. Find the minimum possible sadness of Snuke. | ['N = int(input())\nA = list(map(int,input().split()))\n\nb = 0\nif N%2 == 0:\n b = (A[N//2-1]+A[N//2])//2 - N//2 \nelse:\n b = A[N//2] - N//2 - 1\nprint(b)\nb += 1\nans = 0\nfor i in range(N):\n ans += abs(A[i]-(b+i+1))\n\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nB = [A[i]-i-1 for i in range(N)]\nB.sort()\nb = B[N//2]\nprint(sum([abs(A[i]-b-i-1) for i in range(N)]))'] | ['Wrong Answer', 'Accepted'] | ['s899396228', 's361842585'] | [26832.0, 26848.0] | [131.0, 221.0] | [227, 153] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.