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
p02725
u797550216
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int,input().split())\n\na = list(map(int,input().split()))\nk_diff = []\n\nfor i in range(1,n):\n k_diff.append(abs(a[i-1] - a[i]))\n\nk_diff.append(k - a[-1])\n\nprint(k - max(k_diff))', 'k,n = map(int,input().split())\n\na = list(map(int,input().split()))\nk_diff = []\n\nfor i in range(1,n):\n k_diff.append(a[i] - a[i-1])\n\nk_diff.append((k-a[-1])+a[0])\n\nprint(k - max(k_diff))\n']
['Wrong Answer', 'Accepted']
['s445289868', 's881706522']
[26444.0, 26444.0]
[126.0, 116.0]
[188, 189]
p02725
u798675549
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K=int(input().split()[0])\nlst=list(map(int,input().split()))\nlst.append(K-sum(lst))\nprint(K-min(lst))', 'K=int(input().split()[0])\nlst1=list(map(int,input().split()))\nlst2=[lst1[i+1]-lst1[i] for i in range(len(lst1)-1)]\nlst2.append(K+lst1[0]-lst1[-1])\nprint(K-max(lst2))']
['Wrong Answer', 'Accepted']
['s785235111', 's585275894']
[26060.0, 26444.0]
[71.0, 102.0]
[101, 165]
p02725
u806779442
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int,input().split())\na = list(map(int,input().split()))\n\nend = a[0] + k - a[n-1]\nb = []\nb.append(end)\n\nfor i in range(0,n-1):\n diff = a[i+1] - a[i]\n b.append(diff)\n\nb.sort(reverse=True)\nprint(k-max)', 'k, n = map(int,input().split())\na = list(map(int,input().split()))\n\nans = a[0] + k - a[n-1]\nfor i in range(n-1):\n diff = a[i+1] - a[i]\n ans = max(ans, diff)\n\nprint(k - ans)']
['Runtime Error', 'Accepted']
['s204677701', 's254492075']
[26060.0, 26444.0]
[147.0, 157.0]
[215, 178]
p02725
u810778810
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['info = list(map(int,input().split()))\nk=info[0]\nn=info[1]\na = list(map(int,input().split()))\nMAX=0\n\nfor i in range(n-1):\n if a[i+1]-a[i] > MAX:\n MAX=a[i+1]-a[i]\nif abs(k-a[n-1]) > MAX:\n MAX=abs(k-a[n-1])\nprint(str(k-MAX))', 'info = list(map(int,input().split()))\nk=info[0]\nn=info[1]\na = list(map(int,input().split()))\nMAX=0\n\nfor i in range(n-1):\n if a[i+1]-a[i] > MAX:\n MAX=a[i+1]-a[i]\nif a[0]+k-a[n-1] > MAX:\n MAX=a[0]+k-a[n-1]\nprint(str(k-MAX))']
['Wrong Answer', 'Accepted']
['s657593383', 's880960499']
[26444.0, 26444.0]
[104.0, 106.0]
[238, 238]
p02725
u813993459
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\n \ntmp =list(map(int, input().split()))\nnum=list(map(int, input().split()))\n \na[a>int(tmp[0]//2)]=a[a>int(tmp[0]//2)]-int(tmp[0]//2)\nprint(sum(a))', 'import numpy as np\n\ntmp =list(map(int, input().split()))\nnum=np.array(list(map(int, input().split())))\n\nr = np.diff(num).sum()\n\nl=np.array(num[num>int(tmp[0]//2)].tolist()+num[num<=int(tmp[0]//2)].tolist())\nl[l>int(tmp[0]//2)]=tmp[0]-l[l>int(tmp[0]//2)]\nl=np.abs(np.diff(l)).sum()\n\nif l>r:\n print(r)\nelse:\n print(l)', 'import numpy as np\n\ntmp = list(map(int, input().split()))\nnum = list(map(int, input().split()))\n\nprint(np.diff(num).sum()-np.diff(num).max())\n', 'import numpy as np\n \ntmp =list(map(int, input().split()))\na=np.array(list(map(int, input().split())))\n \na[a>int(tmp[0]/2)]=tmp[0]-a[a>int(tmp[0]/2)]\nprint(sum(a))', 'import numpy as np\n \ntmp =list(map(int, input().split()))\na=np.array(list(map(int, input().split())))\n\na[a>int(tmp[0]//2)]=tmp[0]-a[a>int(tmp[0]//2)]\nprint(sum(a))', 'import numpy as np\n \ntmp =list(map(int, input().split()))\na=np.array(list(map(int, input().split())))\n \na[a>int(tmp[0]//2)]=a[a>int(tmp[0]//2)]-int(tmp[0]//2)\nprint(sum(a))', 'import numpy as np\n\ntmp =list(map(int, input().split()))\nnum=list(map(int, input().split()))\n\na[a>int(tmp[0]//2)]=np.abs(a[a>int(tmp[0]//2)]-int(tmp[0]//2))\n\nprint(sum(a))', 'import numpy as np\n \ntmp =list(map(int, input().split()))\nnum=list(map(int, input().split()))\n\nnum.append(num[0]+tmp[0])\n\nprint(np.diff(num).sum()-np.diff(num).max())\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s054555794', 's130990233', 's557400188', 's693500649', 's737702369', 's792435284', 's813924704', 's047955463']
[42708.0, 42844.0, 42848.0, 42924.0, 34172.0, 42800.0, 42572.0, 34132.0]
[1728.0, 977.0, 668.0, 416.0, 278.0, 1305.0, 334.0, 236.0]
[164, 321, 142, 162, 163, 172, 171, 167]
p02725
u814885356
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nA = input().split()\nA = [int(val) for val in A]\nA_org = min(A)\nA = [val - A_org for val in A]\nA.sort()\ndist = []\nfor i in range(len(A)):\n if i != len(A)-1:\n dist.append(A[i+1]-A[i])\n else:\n dist.append(K-A[i])\nprint(max(dist)-min(dist))', 'K, N = map(int, input().split())\nA = input().split()\nA = [int(val) for val in A]\nA_org = min(A)\nA = [val - A_org for val in A]\nA.sort()\ndist = []\nfor i in range(len(A)):\n if i != len(A)-1:\n dist.append(A[i+1]-A[i])\n else:\n dist.append(K-A[i])\nprint(K - max(dist))']
['Wrong Answer', 'Accepted']
['s682544510', 's938897741']
[26444.0, 24948.0]
[176.0, 170.0]
[277, 271]
p02725
u819593641
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\n\nk, n = map(int, input().split())\na = list(map(int, input().split()))\na.append(k)\nb = []\nfor k in range(len(a)):\n b.append(a[k+1] - a[k])\nprint(k - argmax(b))', 'k, n = map(int, input().split())\na = list(map(int, input().split()))\nb = []\nfor l in range(len(a)-1):\n b.append(a[l+1] - a[l])\nb.append(k-a[n-1]+a[0])\nprint(k - max(b))']
['Runtime Error', 'Accepted']
['s797641731', 's603909818']
[42676.0, 26420.0]
[397.0, 115.0]
[178, 169]
p02725
u823398800
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['#C traveling salesman around lake\n\nk,n = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(a)\nans = 0\nfor i in range(n-1):\n if a[i+1] - a[i] > ans:\n ans = a[i+1] - a[i]\n\nlast = a[0] + k - a[n-1]\nif last > ans:\n ans = last\n\nprint(k-ans)', '#C traveling salesman around lake\n\nk,n = map(int, input().split())\na = list(map(int, input().split()))\n\nans = 0\nfor i in range(n-1):\n if a[i+1] - a[i] > ans:\n ans = a[i+1] - a[i]\n\nlast = a[0] + k - a[n-1]\nif last > ans:\n ans = last\n\nprint(k-ans)']
['Wrong Answer', 'Accepted']
['s613899026', 's571610889']
[26444.0, 26444.0]
[124.0, 102.0]
[267, 258]
p02725
u826027240
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['\nN, X, Y = map(int, input().split())\n\n\nmin = []\nans = []\n\n\nfor i in range(0, N -1):\n d = A[i+1] - A[i]\n ans += d\n if d > max:\n max = d\n\n\ndl = K - A[N - 1]\nif dl < max:\n ans = ans - max + dl + A[0]\n\n\nfor j in range(0, N -1):\n print(ans[j])\n', '\nK, N = map(int, input().split())\n\nA = list(map(int, input().split()))\n\n\nans = 0\nmax = 0\n\n\nfor i in range(0, N -1):\n d = A[i+1] - A[i]\n ans += d\n if d > max:\n max = d\n\n\ndl = K - A[N - 1]\nif dl + A[0] < max:\n ans = ans - max + dl + A[0]\n\n\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s933768476', 's236658015']
[3060.0, 26420.0]
[18.0, 130.0]
[398, 450]
p02725
u827306875
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nx1 = list(map(int,input().split()))\nx2 = np.array(x1, dtype=np.int64)\n\nx2 = np.sort(x2)\nsum = 0\n\nfor i in range(N-1):\n sum += x2[1] - x2[0]\n \nprint(sum)', 'import numpy as np\nK, N = map(int, input().split())\nx_list = list(map(int, input().split()))\n\nsub_x_list = x_list.copy()[1:]\nsub_x_list.append(K + x_list[0])\n\nfor i in range(N):\n sub_x_list[i] -= x_list[i]\n \nmax_i = max(sub_x_list)\nprint(K - max_i)']
['Runtime Error', 'Accepted']
['s341897242', 's923569549']
[26444.0, 34176.0]
[65.0, 242.0]
[191, 254]
p02725
u827554201
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['# coding: utf-8\n# Your code here!\n\ninput1 = [int(x) for x in input().split()]\nlake = input1[0]\nhomes = input1[1]\ninput2 = [int(x) for x in input().split()]\n\nresult = 1000000\nlast = homes - 1\nfor x in range(homes):\n forward = 0\n backward = 0\n start = input2[x]\n\n # forward\n if x == 0:\n forward = input2[last] - start\n else:\n forward = (lake - start) + input2[x - 1]\n \n # backward\n if x == last:\n backward = (start) - input2[0]\n else:\n backward = (start) + lake - (input2[x + 1])\n\n print("forward: {}, backward: {}".format(forward, backward))\n result = min(result, forward, backward)\n\nprint(result)\n', '# coding: utf-8\n# Your code here!\n\ninput1 = [int(x) for x in input().split()]\nlake = input1[0]\nhomes = input1[1]\ninput2 = [int(x) for x in input().split()]\n\nresult = 1000000\nlast = homes - 1\nfor x in range(homes):\n forward = 0\n backward = 0\n start = input2[x]\n\n # forward\n if x == 0:\n forward = input2[last] - start\n else:\n forward = (lake - start) + input2[x - 1]\n \n # backward\n if x == last:\n backward = (start) - input2[0]\n else:\n backward = (start) + lake - (input2[x + 1])\n\n #print("forward: {}, backward: {}".format(forward, backward))\n result = min(result, forward, backward)\n\nprint(result)\n']
['Wrong Answer', 'Accepted']
['s953893253', 's951610945']
[26444.0, 26444.0]
[515.0, 261.0]
[661, 662]
p02725
u828873269
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N=(int(x) for x in input().split())\nA = list(map(int,input().split()))\ncheck = K- A[N-1]\n\nfor i in range(N-1):\n if(A[i+1]-A[i]>check):\n check=(A[i+1]-A[i])\n \n\nnum = K - check\nprint(num)', 'K,N=(int(x) for x in input().split())\nA = list(map(int,input().split()))\nprint(K)\nprint(N)\nprint(A)\ncheck = K- A[N-1]\n\nfor i in range(N-1):\n if(A[i+1]-A[i]>check):\n check=(A[i+1]-A[i])\n \n\nnum = K - check\nprint(num)', 'K,N=(int(x) for x in input().split())\nA = list(map(int,input().split()))\ncheck = K- A[N-1] + A[0]\n\nfor i in range(N-1):\n if(A[i+1]-A[i]>check):\n check=A[i+1]-A[i]\n \n\nnum = K - check\nprint(num)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s298308009', 's721021506', 's959546640']
[26436.0, 26420.0, 26444.0]
[102.0, 119.0, 106.0]
[204, 231, 209]
p02725
u830881690
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int, input().split())\na = list(map(int, input().split()))\n\nad = []\nfor i in range(n):\n if i != (n-1):\n ad.append(a[i+1] - a[i])\n if i == (n-1):\n ad.append(k-a[n-1] + a[0])\n\nad_max = max(ad)\nad_max_ind = ad.index(ad_max)\n\nprint(ad_max_ind)\n\nif ad_max_ind == (n-1):\n ans = a[n-1] - a[0]\nif ad_max_ind != (n-1):\n ans = k - a[ad_max_ind+1] + a[ad_max_ind]\n \nprint(ans)', 'k, n = map(int, input().split())\na = list(map(int, input().split()))\n\nad = []\nfor i in range(n):\n if i != (n-1):\n ad.append(a[i+1] - a[i])\n if i == (n-1):\n ad.append(k-a[n-1] + a[0])\n\nad_max = max(ad)\nad_max_ind = ad.index(ad_max)\n\nif ad_max_ind == (n-1):\n ans = a[n-1] - a[0]\nif ad_max_ind != (n-1):\n ans = k - a[ad_max_ind+1] + a[ad_max_ind]\n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s166624262', 's088860168']
[26444.0, 26444.0]
[147.0, 149.0]
[404, 385]
p02725
u831274245
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = [int(i) for i in input().split()]\nA = sorted([int(i) for i in input().split()])\nprint(K - max(y-x for x,y in zip(A,A[1:])))', 'K,N = [int(i) for i in input().split()]\nA = sorted([int(i) for i in input().split()])\nA += [A[0]+K]\nprint(K - max(y-x for x,y in zip(A,A[1:])))']
['Wrong Answer', 'Accepted']
['s159980121', 's229644589']
[26444.0, 26092.0]
[96.0, 95.0]
[129, 143]
p02725
u831311378
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\ndmax = 0\nfor i in range(1,n):\n if a[i]-a[i-1]>dmax:\n dmax = a[i]-a[i-1]\nprint(k-dmax)', 'k,n = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\ndmax = 0\nfor i in range(1,n):\n if a[i]-a[i-1]>dmax:\n dmax = a[i]-a[i-1]\nif k-a[-1]+a[0] > dmax:\n dmax = k-a[-1]+a[0]\nprint(k-dmax)']
['Wrong Answer', 'Accepted']
['s478269086', 's925345688']
[26420.0, 25452.0]
[112.0, 110.0]
[167, 213]
p02725
u831752983
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input().split())\na=list(map(int,input().split()))\ndist = [k-dist[n-1]+dist[0]]\nfor i in range(n):\n dist.append(a[i+1]-a[i])\n\nprint(k-max(dist))\n', 'k,n=map(int,input().split())\na=list(map(int,input().split()))\ndist = [k-a[n-1]+a[0]]\nfor i in range(n-1):\n dist.append(a[i+1]-a[i])\n\nprint(k-max(dist))\n']
['Runtime Error', 'Accepted']
['s831425759', 's780563667']
[26420.0, 26420.0]
[65.0, 117.0]
[157, 153]
p02725
u833933988
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int, input().split())\na = [int(x) for x in input().split()]\na_ = [x - a[0] for x in a] + [k]\nd = [y - x for x, y in zip(a, a[1:])]\nprint(k - max(d))', 'k, n = map(int, input().split())\na = [int(x) for x in input().split()]\na_ = [x - a[0] for x in a] + [k]\nd = [y - x for x, y in zip(a_, a_[1:])]\nprint(k - max(d))']
['Wrong Answer', 'Accepted']
['s419350873', 's695658201']
[26444.0, 26444.0]
[113.0, 111.0]
[159, 161]
p02725
u834983620
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['a,b = map(int,input().split())\nc = [int(i) for i in input().split()]\n\nresult = sum(c) - c[0]\n\n\n\nprint(result)', 'a,b = map(int,input().split())\naaa = [int(i) for i in input().split()]\n\naaa.append(aaa[0] + a)\n\nresult = [c1 - c0 for c0,c1 in zip(aaa,aaa[0:])]\n\nprint(a - max(result))', 'a,b = map(int,input().split())\naaa = [int(i) for i in input().split()]\n\naaa.append(aaa[0] + a)\n\nresult = [c1 - c0 for c0,c1 in zip(aaa,aaa[1:])]\n\nprint(a - max(result))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s220018734', 's238862104', 's692996658']
[26600.0, 24908.0, 26420.0]
[78.0, 91.0, 90.0]
[109, 168, 168]
p02725
u835322333
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = map(int,(input().split()))\nA = list(map(int,(input().split())))\n\nans = []\nfor i in range(N-1):\n ans.append(A[i+1]-A[i])\n\nans.append(K-A[N-1])\nprint(K-max(ans))', 'K,N = map(int,(input().split()))\nA = list(map(int,(input().split())))\n\nans = []\nfor i in range(N-1):\n ans.append(A[i+1]-A[i])\n\nans.append(K-A[N-1]+A[0])\nprint(K-(max(ans)))']
['Wrong Answer', 'Accepted']
['s422883307', 's148151452']
[26060.0, 26436.0]
[117.0, 118.0]
[168, 175]
p02725
u836589274
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['#C\n\nk, n = map(int, input().split())\n\na = list(map(int, input().split()))\n\nd = []\n\nd.append(a[0])\nfor i in range(n-1):\n d.append(a[i+1] - a[i])\n\nd.append(k - a[n-1])\n# print(d)\n\n# print(max(d))\n\n# print(sum(d))\n\nprint(k - max(d))', '#C\n\nk, n = map(int, input().split())\n\na = list(map(int, input().split()))\n\nd = []\nd.append(a[0])\nfor i in range(n-1):\n d.append(a[i+1] - a[i])\n\nd.append(k - a[n-1])\n\nprint(sum(d) - max(d))', '#C\n\nk, n = map(int, input().split())\n\na = list(map(int, input().split()))\n\nd = []\n\nfor i in range(n-1):\n d.append(a[i+1] - a[i])\n\nd.append(k - a[n-1] + a[0])\n\nprint(k - max(d))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s042721070', 's384755207', 's829896517']
[25840.0, 26060.0, 25840.0]
[116.0, 118.0, 119.0]
[254, 191, 201]
p02725
u839188633
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nans = sum(A)\n\nans -= max((A[(i + 1) % N] - A[i]) % K for i in range(N))\n\nprint(ans)\n', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nans = K - max((A[(i + 1) % N] - A[i]) % K for i in range(N))\n\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s300437434', 's946949141']
[25840.0, 26436.0]
[110.0, 123.0]
[154, 143]
p02725
u842388336
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int, input().split())\nli = list(map(int, input().split()))\nli_2 = []\nfor i in range(1,len(li)):\n li_2.append(li[i]-li[i-1])\nprint(k-max(li_2))\n\n', 'k, n = map(int, input().split())\nli = list(map(int, input().split()))\nprint(k-max(li))', 'k, n = map(int, input().split())\nli = list(map(int, input().split()))\nli_2 = []\nfor i in range(1,len(li)):\n li_2.append(li[i]-li[i-1])\nprint(min(k-max(li_2), li[-1]-li[0]))\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s039282455', 's267502725', 's664622127']
[32352.0, 32376.0, 32276.0]
[107.0, 73.0, 107.0]
[156, 86, 175]
p02725
u844697453
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
["k=list(map(int, input().split(' ')))\na=list(map(int, input().split(' ')))\nm=a[0]\nfor i in range(k[1]):\n if i==k[1]-1:\n if k[0]-a[i]+a[0]>m:\n m=k[1]-a[i]+a[0]>m\n else:\n if a[i+1]-a[i]>m:\n m=a[i+1]-a[i]>m\nprint(k[0]-m)", "k=list(map(int, input().split(' ')))\na=list(map(int, input().split(' ')))\nm=a[0]\nfor i in range(k[1]):\n if i==k[1]-1:\n if k[0]-a[i]+a[0]>m:\n m=k[0]-a[i]+a[0]\n else:\n if a[i+1]-a[i]>m:\n m=a[i+1]-a[i]\nprint(k[0]-m)"]
['Wrong Answer', 'Accepted']
['s911449115', 's647133076']
[26420.0, 25840.0]
[160.0, 119.0]
[258, 254]
p02725
u844895214
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
["import sys\nfrom collections import deque\nimport numpy as np\nimport math\nsys.setrecursionlimit(10**6)\ndef S(): return sys.stdin.readline().rstrip()\ndef SL(): return map(str,sys.stdin.readline().rstrip().split())\ndef I(): return int(sys.stdin.readline().rstrip())\ndef IL(): return map(int,sys.stdin.readline().rstrip().split())\n\ndef Main():\n k,n = IL()\n a = list(IL())\n a.sort()\n dist = []\n for i in range(n):\n if i<n-1:\n dist.append(a[i+1]-a[i])\n else:\n dist.append(k-a[i]+a[0])\n print(dist)\n x = max(dist)\n print(k-x)\n return\n\nif __name__=='__main__':\n Main()", "import sys\ndef IL(): return map(int,sys.stdin.readline().rstrip().split())\n\ndef Main():\n k,n = IL()\n a = list(IL())\n a.sort()\n m = 0\n for i in range(n):\n if i<n-1:\n m = max(m,a[i+1]-a[i])\n else:\n m = max(m,k-a[i]+a[0])\n print(k-m)\n return\n\nif __name__=='__main__':\n Main()"]
['Wrong Answer', 'Accepted']
['s342955098', 's915692506']
[50792.0, 32376.0]
[200.0, 118.0]
[625, 332]
p02725
u845148770
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = map(int, input().split())\nA = list(map(int,input().split()))\n\n\nl_s = []\ncheck = 0\nfor i in range(0,N):\n if(A[i] == 0):\n check =1\nif(check == 1):\n for i in range(1,N):\n l_s.append(A[i]-A[i-1])\n l_s.append(K-A[N-1])\n num = 0\n ans = 99999999999999999\n for i in range(0,N):\n num = K - l_s[i]\n ans = min(ans,num)\n print(ans)\n \nelse: \n for i in range(1,N):\n l_s.append(A[i]-A[i-1])\n l_s.append(K-A[N-1]+A[0])\n print(l_s)\n m1 = max(l_s)\n ans = K-m1\n print(ans)', 'K,N = map(int, input().split())\nA = list(map(int,input().split()))\n\n\nl_s = []\ncheck = 0\nfor i in range(0,N):\n if(A[i] == 0):\n check =1\nif(check == 1):\n A.append(K)\n for i in range(1,N+1):\n l_s.append(A[i]-A[i-1])\n num = 0\n ans = 99999999999999999\n for i in range(0,N):\n num = K - l_s[i]\n ans = min(ans,num)\n print(ans)\n \nelse: \n for i in range(1,N):\n l_s.append(A[i]-A[i-1])\n l_s.append(K-A[N-1]+A[0])\n print(l_s)\n m1 = max(l_s)\n ans = K-m1\n print(ans)', 'K,N = map(int, input().split())\nA = list(map(int,input().split()))\n\n\nl_s = []\ncheck = 0\nfor i in range(0,N):\n if(A[i] == 0):\n check =1\nif(check == 1):\n A.append(K)\n for i in range(1,N+1):\n l_s.append(A[i]-A[i-1])\n num = 0\n ans = 99999999999999999\n for i in range(0,N):\n num = K - l_s[i]\n ans = min(ans,num)\n print(ans)\n \nelse: \n A.append(K)\n for i in range(1,N+1):\n l_s.append(A[i]-A[i-1])\n m1 = max(l_s)\n ans = K-1 -m1\n print(ans)', 'K,N = map(int, input().split())\nA = list(map(int,input().split()))\n\n\nl_s = []\ncheck = 0\nfor i in range(0,N):\n if(A[i] == 0):\n check =1\nif(check == 1):\n A.append(K)\n for i in range(1,N+1):\n l_s.append(A[i]-A[i-1])\n num = 0\n ans = 99999999999999999\n for i in range(0,N):\n num = K - l_s[i]\n ans = min(ans,num)\n print(ans)\n \nelse: \n A.append(K)\n for i in range(1,N+1):\n l_s.append(A[i]-A[i-1])\n m1 = max(l_s)\n ans = K-m1\n print(ans)', 'K,N = map(int, input().split())\nA = list(map(int,input().split()))\n\n\nl_s = []\ncheck = 0\nfor i in range(0,N):\n if(A[i] == 0):\n check =1\nif(check == 1):\n for i in range(1,N):\n l_s.append(A[i]-A[i-1])\n l_s.append(K-A[N-1])\n num = 0\n ans = 99999999999999999\n for i in range(0,N):\n num = K - l_s[i]\n ans = min(ans,num)\n print(ans)\n \nelse: \n for i in range(1,N):\n l_s.append(A[i]-A[i-1])\n l_s.append(K-A[N-1]+A[0])\n m1 = max(l_s)\n ans = K-m1\n print(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s200802382', 's230397779', 's629442800', 's830482369', 's382797873']
[26444.0, 26444.0, 26444.0, 26444.0, 26444.0]
[193.0, 202.0, 194.0, 196.0, 201.0]
[540, 533, 509, 506, 523]
p02725
u845847173
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nA = [int(e) for e in input().split()]\n\nans = 0\nfor i in range(N - 1):\n S = [A[i] - A[i + 1]]\n S.append(A[N] - A[0])\n S.sort\n for n in range(N - 1):\n ans += S[i]\nprint(ans)', 'K, N = map(int, input().split())\nA = [int(e) for e in input().split()]\n\nans = 0\nfor i in range(N - 1):\n S = [A[i + 1] - A[i]]\n S.append((K - A[N - 1]) + A[0])\n m = sorted(S)\n for n in range(N - 1):\n ans += m[n]\nprint(ans)\n', 'K, N = map(int, input().split())\nA = [int(e) for e in input().split()]\n\nans = 0\nS = [(A[i + 1] - A[i]) for i in range(N - 1)]\nS.append((K - A[N - 1]) + A[0])\nS.sort\nm = sorted(S)\nfor n in range(N - 1):\n ans += m[n]\nprint(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s272586745', 's525766534', 's876999521']
[24884.0, 26420.0, 24908.0]
[71.0, 73.0, 153.0]
[223, 241, 229]
p02725
u847165882
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N=map(int,input().split())\nA=[int(s) for s in input().split(" ")]\n\nSmax=0\nfor i in range(K):\n S=0\n if i==0:\n S=max(abs(A[0]-A[-1]),abs(A[0]-A[1]))\n elif i==K-1:\n S=max(abs(A[-1]-A[0]),abs(A[-1]-A[-2]))\n else:\n S=max(abs(A[i]-A[i+1]),abs(A[i]-A[i-1]))\n if Smax<S:\n Smax=S\n\nprint(K-Smax)', 'K,N=map(int,input().split())\nA=[int(s) for s in input().split(" ")]\n\nSmax=0\nfor i in range(len(A)-1):\n S=0\n if i!=K-1:\n S=abs(A[i]-A[i+1])\n else:\n S=abs(A[-1]-A[0])\n if S>Smax:\n Smax=S\n\nprint(K-Smax)', 'K,N=map(int,input().split())\nA=[int(s) for s in input().split(" ")]\n\nSmax=0\nfor i in range(N):\n S=0\n if i!=N-1:\n if A[i+1]>A[i]:\n S=A[i+1]-A[i]\n else:\n S=A[i]-A[i+1]\n else: \n if A[0]>A[-1]:\n S=A[0]-A[-1]\n else:\n S=A[-1]-A[0]\n \n if S>K/2:\n S=K-S\n if Smax<S:\n Smax=S\n\nprint(K-Smax)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s276311333', 's575421481', 's672139861']
[26444.0, 26420.0, 26572.0]
[241.0, 157.0, 212.0]
[330, 232, 383]
p02725
u848336553
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nmax_diff = 0\nfor idx in range(len(a)-1):\n diff = a[idx+1] - a[idx]\n if max_diff < diff:\n max_diff = diff\n\nans = k - max_diff\nprint(ans)\n', 'k, n = input().split()\na = list(map(int, input().split()))\na.sorted()\nmax_diff = 0\nfor idx in range(len(a)-1):\n diff = a[idx+1] - a[idx]\n if max_diff < diff:\n max_diff = diff\n\nans = k - max_diff\nprint(ans)', 'k, n = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nmax_diff = k - a[n-1] + a[0]\nfor idx in range(len(a)-1):\n diff = a[idx+1] - a[idx]\n if max_diff < diff:\n max_diff = diff\nmax_diff = max_diff\nans = k - max_diff\nprint(ans)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s305723180', 's949886781', 's506801487']
[26444.0, 26420.0, 26436.0]
[111.0, 65.0, 110.0]
[219, 210, 253]
p02725
u850087201
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K = int(input())\nN = int(input())\nlists = [int(x) for x in input().split()]\nlists.sort()\nsor = []\nfor i in range(N-1):\n sor.append(lists[i+1]-lists[i])\nsor.append(K-lists[N-1]+lists[0])\nprint(K-max(sor))', '[K,N]= [int(x) for x in input().split()]\n\nlists = [int(x) for x in input().split()]\nlists.sort()\nsor = []\nfor i in range(N-1):\n sor.append(lists[i+1]-lists[i])\nsor.append(K-lists[N-1]+lists[0])\nprint(K-max(sor))']
['Runtime Error', 'Accepted']
['s838235925', 's996353851']
[3060.0, 24636.0]
[17.0, 132.0]
[206, 214]
p02725
u850243304
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\nb = A[0]+(K-A[N-1])\n\nfor i in range(1,N):\n a = max(A[i]-A[i-1])\n\nc = max(a,b)\n\nprint(K-c)\n', 'K,N = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\nc = A[0]+(K-A[N-1])\n\nfor i in range(1,N):\n d = max(d,A[i]-A[i-1])\n\nprint(K-d)\n', 'K, N = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\na = [A[i]-A[i-1] for i in range(1,N-1)]\n\nb = A[0]+(K-A[N-1])\n\nprint(K-max(a,b))\n', 'k,n = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nc = a[0] + (k - a[n-1])\n\nc = max(c,[a[i]-a[i-1] for i in range(1,n)])\n\nprint(k-c)\n', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nfor i in range[N]:\n dif = A[i+1]-A[i]\n\ndif.extend([K-A[N]])\n\nprint(K-max(dif))\n', 'k,n = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nc = a[0] + (k - a[n - 1])\n\nd = max(c,[a[i] - a[i - 1] for i in range(1, n)])\n\nprint(k - d)\n', 'K, N = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\na = [A[i]-A[i-1] for i in range(1,N)]\n\nb = A[0]+(K-A[N-1])\n\nc = max(a,b)\n\nprint(K-c)\n', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\ndif = [A[i+1]-A[i] for i in range(N-1)]\n\ndif.extend([K-A[N]])\n\nprint(K-max(dif))\n', 'k,n = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nb = a[0] + (k - a[n-1])\n\nc = [a[i]-a[i-1] for i in range(1,n)]\n\nprint(max(b,c))\n', 'k,n = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nc = a[0] + (K - a[n-1])\n\nfor i in range(1,N):\n d = max(c, A[i] - A[i-1])\n\nprint(K - d)\n', 'k,n = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nb = a[0] + (k - a[n-1])\n\nc = [a[i]-a[i-1] for i in range(1,n)]\n\nd = max(b,c)\n\nprint(d)\n', 'K,N = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\nc = A[0]+(K-A[N-1])\n\nfor i in range(1,N+1):\n d = max(c,A[i]-A[i-1])\n\nprint(K-d)\n', 'K, N = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\nb = A[0]+(K-A[N-1])\n\na = [A[i]-A[i-1] for i in range(1,N)]\n\nc = max(a,b)\n\nprint(K-c)\n', 'K, N = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\na = [A[i]-A[i-1] for i in range(1,N)]\n\nb = A[0]+(K-A[N-1])\n\nc = max(a,b)\n\nprint(K-c)\n', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nfor i in range(N):\n dif = A[i+1]-A[i]\n\ndif.extend([K-A[N]])\n\nprint(K-max(dif))', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\ndif = [A[i+1]-A[i] for i in range(N)]\n\ndif.extend([K-A[N]])\n\nprint(K-max(dif))\n', 'k,n = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nc = a[0] + (k - a[n - 1])\n\nd = max([a[i] - a[i - 1] for i in range(1, n)])\n\nc = max(c,d)\n\nprint(k - c)\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s113455721', 's131127687', 's139317377', 's159225733', 's178015366', 's351670943', 's417240738', 's512084550', 's621296202', 's632189929', 's715208709', 's765886216', 's795466485', 's918028366', 's944511574', 's993420364', 's321622149']
[31640.0, 31452.0, 31752.0, 31648.0, 32280.0, 31628.0, 31628.0, 32276.0, 31520.0, 31760.0, 31764.0, 31720.0, 31632.0, 31536.0, 32192.0, 32288.0, 31588.0]
[77.0, 72.0, 94.0, 92.0, 71.0, 95.0, 93.0, 91.0, 92.0, 72.0, 95.0, 129.0, 94.0, 93.0, 98.0, 88.0, 96.0]
[173, 160, 160, 161, 152, 170, 165, 151, 159, 169, 166, 162, 165, 165, 151, 149, 182]
p02725
u854867898
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['# maintain overall min \n\n# find the absolute distance and before exiting the first maintain overall min\n# also check the distance of last and first house\ndef findDistBetween(i,j):\n return abs(i - j)\n\ndef minDistfindDistBetweenLastAndFirstHouse(i,j):\n dist = findDistBetween(i, j)\n return K - dist \n\nK, N = input().split()\nAs = input().split()\n\nK = int(K)\nN = int(N)\n\nprint ("As is")\nprint (As)\n# print (As.split())\nA = [0] * len(As)\nfor i in range(len(As)):\n A[i] = int(As[i])\n \n# A = list(map(lambda x: int(x), As))\n# print (A)\n# overAllMin = float(\'inf\')\n# minDist = 0 \n\n# minDist = 0\n# for j in range(N):\n# # print (i, j)\n# minDist += findDistBetween(A[i], A[j])\n# # find the dist b/w last and first house\n# # minDist2 = minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n\n\n\n\n\n# print (overAllMin)\noverAllMin = float(\'inf\')\nArev = list(reversed(A))\ndist1 = 0 \ndist2 = 0\nprevHouse = -1\nfor i in range(N):\n print ("PRev house", prevHouse)\n print ("Next house", A[i])\n\n dist1 = max(findDistBetween(A[i], prevHouse), dist1)\n prevHouse = A[i]\n \n\nma = max(dist1, minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1]))\nprint (K - ma)\n\n# count = 0\n# curHouse = A[i]\n# j = i\n# flag0 = 0 \n# flag1 = 0\n# dist1 = 0 \n# dist2 = 0\n# while count < N:\n# if flag0 is 0:\n# dist1 += findDistBetween(curHouse, A[j])\n# curHouse = A[j]\n# j += 1\n# flag0 = 0\n# count += 1\n\n# if j == N and count < N: \n# print ("in condition")\n# j = 0\n# dist1 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n# flag0 = 1\n \n # count += 1\n\n # print ("dist1", dist1)\n\n # count = 0\n # curHouse = A[i]\n # j = i\n # while count < N:\n # if flag1 is 0:\n # dist2 += findDistBetween(curHouse, A[j])\n # curHouse = A[j]\n # j -= 1\n # count += 1\n # flag1 = 0\n # if j == -1 and count < N: \n # j = N - 1 \n # dist2 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n # flag1 = 1\n # # count += 1 \n# overAllMin = min(dist1, K - findDistBetween(A[0], A[-1]), overAllMin)\n# print (dist1, K - findDistBetween(A[0], A[-1]), overAllMin)\n \n# print (overAllMin) \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n', '# maintain overall min \n\n# find the absolute distance and before exiting the first maintain overall min\n# also check the distance of last and first house\ndef findDistBetween(i,j):\n return abs(i - j)\n\ndef minDistfindDistBetweenLastAndFirstHouse(i,j):\n dist = findDistBetween(i, j)\n return K - dist \n\nK, N = input().split()\nAs = input().split()\n\nK = int(K)\nN = int(N)\n\nprint ("As is")\nprint (As)\n# print (As.split())\nA = [0] * len(As)\nfor i in range(len(As)):\n A[i] = int(As[i])\n \n# A = list(map(lambda x: int(x), As))\n# print (A)\n# overAllMin = float(\'inf\')\n# minDist = 0 \n\n# minDist = 0\n# for j in range(N):\n# # print (i, j)\n# minDist += findDistBetween(A[i], A[j])\n# # find the dist b/w last and first house\n# # minDist2 = minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n\n\n\n\n\n# print (overAllMin)\noverAllMin = float(\'inf\')\nArev = list(reversed(A))\ndist1 = 0 \ndist2 = 0 \nfor i in range(N):\n count = 0\n curHouse = A[i]\n j = i\n flag0 = 0 \n flag1 = 0\n dist1 = 0 \n dist2 = 0\n while count < N:\n if flag0 is 0:\n dist1 += findDistBetween(curHouse, A[j])\n curHouse = A[j]\n j += 1\n flag0 = 0\n count += 1\n\n if j == N and count < N: \n # print ("in condition")\n j = 0\n dist1 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n flag0 = 1\n \n # count += 1\n\n # print ("dist1", dist1)\n\n count = 0\n curHouse = A[i]\n j = i\n while count < N:\n if flag1 is 0:\n dist2 += findDistBetween(curHouse, A[j])\n curHouse = A[j]\n j -= 1\n count += 1\n flag1 = 0\n if j == -1 and count < N: \n j = N - 1 \n dist2 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n flag1 = 1\n # count += 1 \n # print (dist1, dist2, overAllMin)\n overAllMin = min(dist1, dist2, overAllMin)\n \nprint (overAllMin) \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n', '# maintain overall min \n\n# find the absolute distance and before exiting the first maintain overall min\n# also check the distance of last and first house\ndef findDistBetween(i,j):\n return abs(i - j)\n\ndef minDistfindDistBetweenLastAndFirstHouse(i,j):\n dist = findDistBetween(i, j)\n return K - dist \n\nK, N = input().split()\nAs = input().split()\n\nK = int(K)\nN = int(N)\n\n# print ("As is")\n# print (As)\n# print (As.split())\nA = [0] * len(As)\nfor i in range(len(As)):\n A[i] = int(As[i])\n \n# A = list(map(lambda x: int(x), As))\n# print (A)\n# overAllMin = float(\'inf\')\n# minDist = 0 \n\n# minDist = 0\n# for j in range(N):\n# # print (i, j)\n# minDist += findDistBetween(A[i], A[j])\n# # find the dist b/w last and first house\n# # minDist2 = minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n\n\n\n\n\n# print (overAllMin)\noverAllMin = float(\'inf\')\nArev = list(reversed(A))\ndist1 = 0 \ndist2 = 0\nprevHouse = -1\nfor i in range(N):\n # print ("PRev house", prevHouse)\n # print ("Next house", A[i])\n\n dist1 = max(findDistBetween(A[i], prevHouse), dist1)\n prevHouse = A[i]\n \n\nma = max(dist1, minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1]))\nprint (K - ma)\n\n# count = 0\n# curHouse = A[i]\n# j = i\n# flag0 = 0 \n# flag1 = 0\n# dist1 = 0 \n# dist2 = 0\n# while count < N:\n# if flag0 is 0:\n# dist1 += findDistBetween(curHouse, A[j])\n# curHouse = A[j]\n# j += 1\n# flag0 = 0\n# count += 1\n\n# if j == N and count < N: \n# print ("in condition")\n# j = 0\n# dist1 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n# flag0 = 1\n \n # count += 1\n\n # print ("dist1", dist1)\n\n # count = 0\n # curHouse = A[i]\n # j = i\n # while count < N:\n # if flag1 is 0:\n # dist2 += findDistBetween(curHouse, A[j])\n # curHouse = A[j]\n # j -= 1\n # count += 1\n # flag1 = 0\n # if j == -1 and count < N: \n # j = N - 1 \n # dist2 += minDistfindDistBetweenLastAndFirstHouse(A[0], A[-1])\n # flag1 = 1\n # # count += 1 \n# overAllMin = min(dist1, K - findDistBetween(A[0], A[-1]), overAllMin)\n# print (dist1, K - findDistBetween(A[0], A[-1]), overAllMin)\n \n# print (overAllMin) \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s615359987', 's904909392', 's515136746']
[35468.0, 29340.0, 27724.0]
[728.0, 2106.0, 203.0]
[2664, 2274, 2672]
p02725
u857330600
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input())\nl=list(map(int,input()))\nv=[k-l[-1]+l[0]]\nfor i in range(n-1):\n v.append(l[i+1]-l[i])\nv.sort()\nprint(k-v[-1])', 'k,n=map(int,input.split())\nl=list(map(int,input.split()))\nv=[k-l[-1]+l[0]]\nfor i in range(n-1):\n v.append(l[i+1]-l[i])\nv.sort()\nprint(k-v[-1])', 'k,n=map(int,input().split())\nl=list(map(int,input().split()))\nv=[k-l[-1]+l[0]]\nfor i in range(n-1):\n v.append(l[i+1]-l[i])\nv.sort()\nprint(k-v[-1])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s944123524', 's944274407', 's726438793']
[3060.0, 3060.0, 26420.0]
[17.0, 17.0, 139.0]
[131, 143, 147]
p02725
u860002137
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\nk, n = map(int, input().split())\na = np.array(list(map(int, input().split())))\nprint(max(abs(a1 - a2)))', 'import numpy as np\nk, n = map(int, input().split())\na = np.array(list(map(int, input().split())))\nprint(max(abs(a1 - a2)))', 'import numpy as np\nk, n = map(int, input().split())\na = np.array(list(map(int, input().split())))\na = np.append(a, a[0]+k)\nprint(k - max(a[1:] - a[:-1]))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s351621058', 's683031714', 's962069618']
[42708.0, 34172.0, 34148.0]
[368.0, 210.0, 235.0]
[122, 122, 153]
p02725
u861071267
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N=map(int,input().split())\nA=sorted(list(map(int,input().split())))\n\nmax_a = max(A)\nmin_a = min(A)\ndiff_min = max_a - min_a\n\nif diff_min <= K/2:\n print(diff_min)\nelse:\n for i in range(1,N-1):\n tmp = K - (A[i+1] - A[i])\n if tmp < diff_min:\n diff_min = tmp\n tmp = K - (A[i] - A[i-1])\n if tmp < diff_min:\n diff_min = tmp\n\nprint(diff_min)\n', 'K,N=map(int,input().split())\nA=sorted(list(map(int,input().split())))\n\nmax_a = max(A)\nmin_a = min(A)\ndiff_min = max_a - min_a\n\nif N == 2:\n if A[1] - A[0] < K - (A[1] - A[0]):\n diff_min = A[1] - A[0]\n else:\n diff_min = K - (A[1] - A[0])\nelse:\n for i in range(1,N-1):\n tmp = K - (A[i+1] - A[i])\n if tmp < diff_min:\n diff_min = tmp\n tmp = K - (A[i] - A[i-1])\n if tmp < diff_min:\n diff_min = tmp\n\nprint(diff_min)\n']
['Wrong Answer', 'Accepted']
['s223862538', 's317261708']
[26444.0, 26444.0]
[196.0, 191.0]
[393, 482]
p02725
u863964720
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = map(int, input().split())\nA = [int(N) for N in input().split()]\n#print(A[0])\nmax1 = 0\nmax2 = 0\nfor i in range(0,N-1):\n max1 = A[i+1]-A[i]\n if max1>max2:\n max2=max1\nif a[0]==0:\n lastlength = 20-A[N-1]\n if lastlength >max2:\n max2=lastlength\nelse:\n lastlength = A[N-1]-A[0]\n if lastlength>max2:\n max2=lastlength\nprint(20-max2)', 'K,N = map(int, input().split())\nA = [int(N) for N in input().split()]\n#print(A[0])\nsum = 0.0\nfor i in range(0,N):\n sum = sum+A[i]\naverage = sum/N\nprint(average)\n ', 'K,N = map(int, input().split())\nA = [int(N) for N in input().split()]\n#print(A[0])\nmax1 = 0\nmax2 = 0\nfor i in range(0,N-1):\n max1 = A[i+1]-A[i]\n if max1>max2:\n max2=max1\nlastlength = 20-A[N-1]\nif lastlength >max2:\n max2=lastlength\nprint(20-max2)\n ', 'K,N = map(int, input().split())\nA = [int(N) for N in input().split()]\n#print(A[0])\nmax1 = 0\nmax2 = 0\nfor i in range(0,N-1):\n max1 = A[i+1]-A[i]\n if max1>max2:\n max2=max1\nprint(20-max2)', 'K,N = map(int, input().split())\nA = [int(N) for N in input().split()]\n#print(A[0])\nmax1 = 0\nmax2 = 0\nfor i in range(0,N-1):\n max1 = A[i+1]-A[i]\n if max1>max2:\n max2=max1\nif A[0]==0:\n lastlength = K-A[N-1]\n if lastlength >max2:\n max2=lastlength\nelse:\n lastlength = K-A[N-1]+A[0]\n if lastlength>max2:\n max2=lastlength\nprint(K-max2)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s361631144', 's794983138', 's881772385', 's907283380', 's726770236']
[24948.0, 24908.0, 26436.0, 26444.0, 26444.0]
[119.0, 121.0, 118.0, 119.0, 122.0]
[368, 168, 266, 197, 368]
p02725
u867826040
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int,input().split())\na=list(map(int,input().split()))\nprint(sum(a)//2)', 'k,n = map(int,input().split())\na=list(map(int,input().split()))\nb=[i for i in a if i<k//2]\nc=[i for i in a if i>=k//2]\nprint(k-max(c)-max(b))', 'k,n = map(int,input().split())\na=list(map(int,input().split()))\nans=(a[0]-a[-1])+k\nfor i in range(n-1):\n ans=max(a[i+1]-a[i],ans)\nprint(k-ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s222216991', 's457203989', 's236189159']
[26444.0, 26060.0, 26420.0]
[72.0, 107.0, 152.0]
[80, 141, 143]
p02725
u869265610
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\na,b=list(map(int,input().split()))\nC=list(map(int,input().split()))\n\ndef getnear(list,num):\n near=np.abs(np.asarray(list)-num).argmin()\n return list[near]\n\nS=sorted(C)\nH=getnear(C,a/2)\nr=abs(H+abs(a-S[0]))\nl=abs(H+abs(a-S[-1]))\nif r>l:\n print(l)\nelse:\n print(r)', 'a,b=map(int,input().split())\nL=list(map(int,input().split()))\nrest=L[0]+a-L[-1]\nfor i in range(b-1):\n U=L[i+1]-L[i]\n rest=max(rest,U)\nprint(a-rest)\n ']
['Wrong Answer', 'Accepted']
['s059747879', 's100130272']
[50580.0, 32276.0]
[178.0, 132.0]
[284, 152]
p02725
u869917163
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = map(int,input().split())\nA_list = list(map(int,input().split())\nA_list.append(K+A_list[0])\nA_split = []\ni for in range(N):\n split = A_list[i+1] - A_list[i]\n A_split.append(split)\n\nA_split.pop(A_split.index(max(A_split)))\nprint(sum(A_split))', 'K,N = map(int,input().split())\nA_list = list(map(int,input().split()))\nA_list.append(K + A_list[0])\nA_split = []\nfor i in range(N):\n A_split.append(A_list[i+1]-A_list[i])\n\nA_split.pop(A_split.index(max(A_split)))\nprint(sum(A_split))']
['Runtime Error', 'Accepted']
['s816517224', 's200036709']
[2940.0, 26444.0]
[17.0, 120.0]
[252, 235]
p02725
u870575557
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nfor i, num in enumerate(a):\n if num>(k/2):\n a[i] = num - k\n\nprint(max(a) - min(a))\n\n', 'k,n = list(map(int, input().split()))\na = list(map(int, input().split()))\n"""\nans = max(a) - min(a)\nfor i, num in enumerate(a):\n if num>(k/2):\n a[i] = num - k\n\nprint(min(ans,max(a) - min(a)))\n\nmin\nabs(ai-bi)\nabs(ai-(bi-k))\n"""\ndef saitan(num1,num2,k):\n return min(abs(num1 - num2), abs(num1-(num2-k)))\n\nbb = saitan(a[0], a[n-1], k)\nfor i in range(1,n):\n bb = max(bb, saitan(a[i], a[i-1], k))\n\nprint(k-bb)']
['Wrong Answer', 'Accepted']
['s091448425', 's139933059']
[26420.0, 25840.0]
[126.0, 222.0]
[169, 420]
p02725
u871303155
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\npoints = list(map(int, input().split()))\nmax_index = -1\nmax_value = -1\n\nfor index in range(1, N):\n d = points[index] - points[index-1] \n if d > max_value:\n max_index = index\n max_value = d\n\nstart = K - points[max_index]\nend = points[max_index-1]\n\nprint(start + end)', 'K, N = map(int, input().split())\npoints = list(map(int, input().split()))\nmax_index = -1\nmax_value = -1\n\nfor index in range(1, N):\n d = points[index] - points[index-1] \n if d > max_value:\n max_index = index\n max_value = d\n\nstart = K - points[max_index]\nend = points[max_index-1]\n\nl = start + end\nplane_l = points[-1] - points[0]\nif l <= plane_l:\n print(l)\nelse:\n print(plane_l)']
['Wrong Answer', 'Accepted']
['s216674528', 's412347730']
[25840.0, 26444.0]
[113.0, 112.0]
[308, 389]
p02725
u872158847
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = input().split()\nK = int(K)\nN = int(N)\nA = list(map(int, input().split()))\n\nmax = 0\nfor i in range(1, N):\n if max < (A[i] - A[i-1]):\n max = A[i] - A[i-1]\nif (max < A[N-1] - A[0]) and ( A[N-1] - A[0]) < K/2:\n max = A[N-1] - A[0]\nprint(K - max)\n', 'K, N = input().split()\nK = int(K)\nN = int(N)\nA = list(map(int, input().split()))\nA.append(K + A[0])\nmax = 0\nfor i in range(N):\n if max < (A[i+1] - A[i]):\n max = A[i+1] - A[i]\nprint(K - max)\n']
['Wrong Answer', 'Accepted']
['s670417888', 's180193055']
[26444.0, 26444.0]
[105.0, 107.0]
[262, 200]
p02725
u874000404
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['\n\ndef quick_sort(arr):\n left = []\n right = []\n if len(arr) <= 1:\n return arr\n\n \n # ref = random.choice(arr)\n ref = arr[0]\n ref_count = 0\n\n for ele in arr:\n if ele < ref:\n left.append(ele)\n elif ele > ref:\n right.append(ele)\n else:\n ref_count += 1\n left = quick_sort(left)\n right = quick_sort(right)\n return left + [ref] * ref_count + right\n\n\nif __name__ == "__main__":\n k,n = list((map(int, input().split(\' \'))))\n a = list(map(int, input().split(\' \')))\n a = quick_sort\n result = 0\n for i in range(1,n):\n length = a[i]-a[i-1]\n result = max(length, result)\n \n length = a[0] + (k-a[n-1])\n result = max(result, length)\n print(k-result)\n \n\n\n\n\n\n \n\n# print(i)\n# if i%5==4:\n# break', '\ndef quick_sort(arr):\n left = []\n right = []\n if len(arr) <= 1:\n return arr\n\n \n # ref = random.choice(arr)\n ref = arr[0]\n ref_count = 0\n\n for ele in arr:\n if ele < ref:\n left.append(ele)\n elif ele > ref:\n right.append(ele)\n else:\n ref_count += 1\n left = quick_sort(left)\n right = quick_sort(right)\n return left + [ref] * ref_count + right\n\n\nif __name__ == "__main__":\n k,n = list((map(int, input().split(\' \'))))\n a = list(map(int, input().split(\' \')))\n a = quick_sort\n result = 0\n for i in range(1,n):\n length = a[i]-a[i-1]\n result = max(length, result)\n \n length = a[0] + (k-a[n-1])\n result = max(result, length)\n print(k-result)\n \n\n\n\n\n\n \n\n# print(i)\n# if i%5==4:\n# break', '\ndef quick_sort(arr):\n left = []\n right = []\n if len(arr) <= 1:\n return arr\n\n \n # ref = random.choice(arr)\n ref = arr[0]\n ref_count = 0\n\n for ele in arr:\n if ele < ref:\n left.append(ele)\n elif ele > ref:\n right.append(ele)\n else:\n ref_count += 1\n left = quick_sort(left)\n right = quick_sort(right)\n return left + [ref] * ref_count + right\n\n\nif __name__ == "__main__":\n k,n = list((map(int, input().split(\' \'))))\n a = list(map(int, input().split(\' \')))\n \n result = 0\n for i in range(1,n):\n length = a[i]-a[i-1]\n result = max(length, result)\n \n length = a[0] + (k-a[n-1])\n result = max(result, length)\n print(k-result)\n \n\n\n\n\n\n \n\n# print(i)\n# if i%5==4:\n# break']
['Runtime Error', 'Runtime Error', 'Accepted']
['s690151786', 's884766559', 's751284194']
[26444.0, 26444.0, 26444.0]
[63.0, 64.0, 143.0]
[952, 951, 953]
p02725
u875449556
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int, input().split())\nA = list(map(int, input().split()))\n\nx = max(A)\nprint(sum(A) - x)', 'k,n = map(int, input().split())\nA = list(map(int, input().split()))\n\nx = k - A[n-1]\nz = A[0]\nx = max(x,z)\nfor i in range(1,n):\n y = A[i]-A[i-1]\n if y > x:\n x = y\n\nprint(k-x)', 'k,n = map(int, input().split())\nA = list(map(int, input().split()))\n\nx = k - A[-1]\nfor i in range(1,n):\n y = A[i]-A[i-1]\n if y > x:\n x = y\n\nprint(k-x)', 'k,n = map(int, input().split())\nA = list(map(int, input().split()))\n\nx = k + A[0] - A[n-1]\n\nfor i in range(1,n):\n y = A[i]-A[i-1]\n if y > x:\n x = y\n\nprint(k-x)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s271607403', 's338636893', 's495893614', 's256126438']
[26420.0, 26436.0, 26444.0, 26060.0]
[70.0, 111.0, 115.0, 110.0]
[97, 186, 163, 172]
p02725
u878212264
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['arrayNM = list(map(int, input().split()))\narray = list(map(int, input().split()))\nroute = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]\nfor i in range(1,arrayNM[1]):\n route.append(array[i] - array[i-1])\n \nMax = max(route)\nmaxIndex = route.index(Max)\ndistance = 0\n\nfor i in range(0,maxIndex):\n distance += route[i]\n\nfor i in range(maxIndex + 1, array[1]):\n distance += route[i]\n\nprint(distance)\nprint(route)\n\n', 'arrayNM = list(map(int, input().split()))\narray = list(map(int, input().split()))\nroute = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]\nfor i in range(1,arrayNM[1]):\n route.append(array[i] - array[i-1])\n \nMax = max(route)\nmaxIndex = route.index(Max)\ndistance = 0\n\nfor i in range(0,maxIndex):\n distance += route[i]\n\nfor i in range(maxIndex + 1, array[1]):\n distance += route[i]\n\nprint(distance)\n\n', 'arrayNM = list(map(int, input().split()))\narray = list(map(int, input().split()))\nroute = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]\nfor i in range(1,arrayNM[1]):\n route.append(array[i] - array[i-1])\n \nMax = max(route)\nmaxIndex = route.index(Max)\ndistance = 0\n\nfor i in range(0,maxIndex):\n distance += route[i]\n\nfor i in range(maxIndex, array[0]):\n distance += route[i]\n\nprint(distance)\nprint(route)\n\n', 'arrayNM = list(map(int, input().split()))\narray = list(map(int, input().split()))\nroute = [array[0] + arrayNM[0] - array[arrayNM[1] - 1]]\nfor i in range(1,arrayNM[1]):\n route.append(array[i] - array[i-1])\n \nMax = max(route)\nmaxIndex = route.index(Max)\ndistance = 0\n\nfor i in range(0,maxIndex):\n distance += route[i]\n\nfor i in range(maxIndex + 1, arrayNM[1]):\n distance += route[i]\n\nprint(distance)\n\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s108993823', 's751720866', 's820178101', 's633770753']
[26444.0, 26444.0, 26444.0, 26444.0]
[156.0, 143.0, 155.0, 151.0]
[414, 401, 410, 403]
p02725
u884323674
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nA = [int(i) for i in input().split()]\n\nmax_dist = A_dist[0] = A[0] + (K - A[-1])\nfor i in range(1, N):\n if A[i] - A[i-1] > min_dist:\n max_dist = A[i] - A[i-1]\n\nprint(K - max_dist)', 'K, N = map(int, input().split())\nA = [int(i) for i in input().split()]\n\nmax_dist = A[0] + (K - A[-1])\nfor i in range(1, N):\n if A[i] - A[i-1] > max_dist:\n max_dist = A[i] - A[i-1]\n\nprint(K - max_dist)']
['Runtime Error', 'Accepted']
['s578194141', 's827093131']
[26444.0, 26444.0]
[74.0, 108.0]
[222, 210]
p02725
u884601206
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input().split())\nA=list(map(int,input().split()))\nd=[0]*len(A)\nfor i in range(len(A)):\n if i==0:\n d[i]=A[len(A)]-A[i]\n else:\n d[i]=k-A[i] + A[i-1]\n \nprint(min(A))\n', 'k,n=map(int,input().split())\nA=list(map(int,input().split()))\nd=[0]*n\nd[0]=A[n-1]-A[0]\nfor i in range(1,n):\n d[i]=k-A[i] + A[i-1]\n \nprint(min(d))\n']
['Runtime Error', 'Accepted']
['s930954900', 's871700380']
[26444.0, 26436.0]
[68.0, 129.0]
[186, 150]
p02725
u884679979
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input().split())\nlist=list(input().split())\ndif_list=[]\n\nfor i in range(n):\n if i == 0:\n dif_list.append(k-list[-1]+list[0])\n else:\n dif_list.append(list[i]-list[i-1])\n\nprint(k-max(dif_list))', 'k,n=map(int,input().split())\nlist=list(map(int,input().split()))\ndif_list=[]\n\nfor i in range(n):\n if i == 0:\n dif_list.append(k-list[-1]+list[0])\n else:\n dif_list.append(list[i]-list[i-1])\n\nprint(k-max(dif_list))']
['Runtime Error', 'Accepted']
['s561321068', 's163769220']
[20044.0, 26444.0]
[36.0, 126.0]
[211, 220]
p02725
u890785941
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['f=list(map(int,input().split()))\nk=f[0];n=f[1]\ndists=list(map(int,input().split()))\nprev=0\nmaxdist=0\nfor d in range(len(dists)):\n maxdist=max(maxdist,abs(prev-dists[d]))\n prev=dists[d]\na=max(maxdist,maxdist-dists[len(dists)-1]+dists[0]) \nans=k-a\nprint(ans)\n', 'f=list(map(int,input().split()))\nk=f[0];n=f[1]\ndists=list(map(int,input().split()))\nprev=0\nmaxdist=0\nfor d in range(1,len(dists)):\n maxdist=max(maxdist,abs(prev-dists[d]))\n prev=dists[d]\na=max(maxdist,maxdist-dists[len(dists)]+dists[0]) \nans=k-a\nprint(ans)', 'f=list(map(int,input().split()))\nk=f[0];n=f[1]\ndists=list(map(int,input().split()))\nprev=0\nmaxdist=0\nfor d in range(n):\n maxdist=max(maxdist,abs(prev-dists[d]))\n prev=dists[d]\nmaxdist=max(maxdist,maxdist-dists[len(dists)-1]+dists[0]) \nans=k-maxdist\nprint(ans)\n', 'k,n = map(int, input().split())\na = list(map(int, input().split()))\nmax_dis = 0\nfor i in range(n):\n if i == n-1:\n max_dis = max(max_dis,a[0]+k-a[i])\n else:\n max_dis = max(max_dis,a[i+1]-a[i])\nprint(k-max_dis)\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s006492610', 's316875951', 's774054094', 's995583979']
[26444.0, 26060.0, 26000.0, 26420.0]
[152.0, 158.0, 155.0, 177.0]
[260, 259, 263, 229]
p02725
u891504219
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['def main():\n K,N = map(int,input().split())\n A = list(map(int,input().split()))\n Aa = []\n for i in range(1,N):\n Aa.append(A[i]-A[i-1])\n Aa.append(K-A[N-1]+A[0])\n print(Aa)\n print(sum(Aa)-max(Aa))\n\nif __name__ == "__main__":\n main()', 'def main():\n K,N = map(int,input().split())\n A = list(map(int,input().split()))\n Aa = []\n for i in range(1,N):\n Aa.append(A[i]-A[i-1])\n Aa.append(K-A[N-1]+A[0])\n print(sum(Aa)-max(Aa))\n\nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s169709591', 's716056291']
[26436.0, 26100.0]
[108.0, 104.0]
[262, 248]
p02725
u891516200
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = [int(x) for x in input().split()]\nA = list([int(x) for x in input().split()])\n\nresult = []\n\nfor i in range(N):\n if i == N - 1:\n result.append(K - A[i] + A[0])\n else:\n result.appnd(A[i + 1] - A[i])\n\nresult.sort()\n\nprint(sum(result[:-1]))\n', 'K, N = [int(x) for x in input().split()]\nA = list([int(x) for x in input().split()])\n\nresult = []\n\nfor i in range(N):\n if i == N - 1:\n result.append(K - A[i] + A[0])\n else:\n result.append(A[i + 1] - A[i])\n\nresult.sort()\n\nprint(sum(result[:-1]))\n']
['Runtime Error', 'Accepted']
['s465874099', 's470982485']
[31512.0, 31640.0]
[75.0, 136.0]
[264, 265]
p02725
u892796322
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import copy\n\nK,N = map(int, input().split())\nAn = list(map(int, input().split()))\nans = [max(An) - min(An)]\nfor i in range(len(An)/2,len(An)):\n A_list = copy.copy(An)\n A_list[i] = A_list[i]-K\n ans.append(max(A_list) - min(A_list))\nprint(min(ans))', 'import numpy as np\n\nK,N = map(int, input().split())\nAn = list(map(int, input().split()))\narr = np.array(An)\narr = np.diff(arr)\nans = list(arr)\nans.append(K-An[-1]+An[0])\n# print(ans)\nans.remove(max(ans))\nprint(sum(ans))']
['Runtime Error', 'Accepted']
['s838689583', 's698142491']
[26932.0, 34164.0]
[179.0, 406.0]
[255, 219]
p02725
u892882715
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import sys\nread = sys.stdin.buffer.read\n\nK, N, *A = map(int, read.split())\n\nmax_distance = K + (A[0] - A[-1])\n \nfor i in range(1, N):\n max_distance = max(max_distance, A[i] - A[i - 1])\n \nprint(K - max_distance)', 'K, N = map(int, input().split())\nA = list(map(int, intput().split()))\n\nmax_distance = K + (A[0] - A[-1])\n\nfor i in range(1, N):\n max_distance = max(max_distance, A[i] - A[i - 1])\n \nprint(K - max_distance)', 'import sys\nread = sys.stdin.buffer.read\n \nK, N, *A = map(int, read().split())\n \nmax_distance = K + (A[0] - A[-1])\n \nfor i in range(1, N):\n max_distance = max(max_distance, A[i] - A[i - 1])\n \nprint(K - max_distance)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s198405353', 's205420685', 's276708940']
[3060.0, 3060.0, 20448.0]
[17.0, 17.0, 132.0]
[212, 206, 216]
p02725
u894934980
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nA = list(map(int, input().split()))\nans = 0\nfor a in A:\n if a > K // 2:\n ans += a - K // 2\n else:\n ans += a\n\nprint(ans)\n', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\nA.append(A[0] + K)\nmax_diff = -1\nfor i in range(1, N + 1):\n max_diff = max(max_diff, A[i] - A[i - 1])\nprint(K - max_diff)']
['Wrong Answer', 'Accepted']
['s265304902', 's304736061']
[25836.0, 26444.0]
[119.0, 135.0]
[173, 193]
p02725
u895592784
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\nk, n = map(int, input().split())\na = np.array(list(map(int, input().split())))\nmini = -1\nfor i in a:\n tmp = a - i\n tmp = np.abs(tmp)\n if mini == -1:\n mini = max(tmp) - min(tmp)\n else:\n mini = min(mini, max(tmp) - min(tmp))\nprint(mini)', '\nimport numpy as np\nk, n = map(int, input().split())\na = np.array(list(map(int, input().split())))\nmaxi = -1\nfor i in range(0, len(a)):\n if i == 0:\n tmp = max(abs((a[i] + k) - a[i - 1]), abs(a[i] - a[i + 1]))\n elif 0 < i < len(a) - 1:\n tmp = max(abs(a[i] - a[i - 1]), abs(a[i] - a[i + 1]))\n else:\n tmp = max(abs(a[i] - a[i-1]), abs(a[i] - (a[0] + k)))\n if maxi == -1:\n maxi = tmp\n else:\n maxi = max(maxi, tmp)\nprint(k - maxi)']
['Wrong Answer', 'Accepted']
['s684483786', 's176832169']
[34112.0, 34184.0]
[2113.0, 871.0]
[279, 492]
p02725
u899457989
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K , N = map(int, input().split())\nA = sorted(list(map(int, input().split())))\nB = []\n\nmax = K - A[-1] + A[0]\nB.append(max)\nind = 0\nfor i in range(1, N, 1):\n\t_max = A[i] - A[i-1]\n\tB.append(_max)\n\tif _max < 0:\n\t\t_max = K + _max\n\tif _max > max:\n\t\tmax = _max\n\t\tind = i\ndis1 = 0\nfor i in range(1, N, 1):\n\tif i + ind >= N:\n\t\tdis1 += B[(i + ind) - N]\n\telse:\n\t\tdis1 += B[(i + ind)]\n\tprint(dis1)', 'K , N = map(int, input().split())\nA = sorted(list(map(int, input().split())))\nB = []\n\nmax = K - A[-1] + A[0]\nB.append(max)\nind = 0\nfor i in range(1, N):\n\t_max = A[i] - A[i-1]\n\tB.append(_max)\n\tif _max < 0:\n\t\t_max = K + _max\n\tif _max > max:\n\t\tmax = _max\n\t\tind = i\ndis1 = 0\n\nfor i in range(1, N):\n\tif i + ind >= N:\n\t\tdis1 += B[(i + ind) - N]\n\telse:\n\t\tdis1 += B[(i + ind)]\n \nprint(dis1)']
['Wrong Answer', 'Accepted']
['s319072645', 's443076467']
[26444.0, 26444.0]
[370.0, 205.0]
[386, 389]
p02725
u899929023
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = list(map(int,input().split(" ")))\nA = list(map(int,input().split(" ")))\nmax_dist = 0\nfor i in range(len(A)-1):\n if A[i+1]-A[i] > max_dist:\n max_dist = A[i+1]-A[i] \nprint(k-max_dist)\n ', 'k,n = list(map(int,input().split(" ")))\nA = list(map(int,input().split(" ")))\nmax_dist = 0\nfor i in range(len(A)-1):\n if A[i+1]-A[i] > max_dist:\n max_dist = A[i+1]-A[i] \nif A[0]+k-A[-1] > max_dist:\n max_dist = A[0]+k-A[-1]\nprint(k-max_dist)\n \n']
['Wrong Answer', 'Accepted']
['s301119193', 's875334864']
[26444.0, 26420.0]
[103.0, 100.0]
[194, 249]
p02725
u902151549
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['# coding: utf-8\nimport re\nimport math\nfrom collections import defaultdict\nimport itertools\nfrom copy import deepcopy\nimport random\nfrom heapq import heappop,heappush\nimport time\nimport os\nimport queue\nimport sys\nimport datetime\nfrom functools import lru_cache\n#@lru_cache(maxsize=None)\nreadline=sys.stdin.readline\nsys.setrecursionlimit(2000000)\n#import numpy as np\nalphabet="abcdefghijklmnopqrstuvwxyz"\nmod=int(10**9+7)\ninf=int(10**20)\ndef yn(b):\n if b:\n print("yes")\n else:\n print("no")\ndef Yn(b):\n if b:\n print("Yes")\n else:\n print("No")\ndef YN(b):\n if b:\n print("YES")\n else:\n print("NO")\nclass union_find():\n def __init__(self,n):\n self.n=n\n self.P=[a for a in range(N)]\n self.rank=[0]*n\n \n def find(self,x):\n if(x!=self.P[x]):self.P[x]=self.find(self.P[x])\n return self.P[x]\n \n def same(self,x,y):\n return self.find(x)==self.find(y)\n \n def link(self,x,y):\n if self.rank[x]<self.rank[y]:\n self.P[x]=y\n elif self.rank[y]<self.rank[x]:\n self.P[y]=x\n else:\n self.P[x]=y\n self.rank[y]+=1\n \n def unite(self,x,y):\n self.link(self.find(x),self.find(y))\n \n def size(self):\n S=set()\n for a in range(self.n):\n S.add(self.find(a))\n return len(S)\ndef is_power(a,b):\n now=b\n while now<a:\n now*=b\n if now==a:return True\n else:return False\ndef bin_(num,size):\n A=[0]*size\n for a in range(size):\n if (num>>(size-a-1))&1==1:\n A[a]=1\n else:\n A[a]=0\n return A\ndef get_facs(n,mod_=0):\n A=[1]*(n+1)\n for a in range(2,len(A)):\n A[a]=A[a-1]*a\n if(mod>0):A[a]%=mod_\n return A\ndef comb(n,r,mod,fac):\n if(n-r<0):return 0\n return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod\ndef next_comb(num,size):\n x=num&(-num)\n y=num+x\n z=num&(~y)\n z//=x\n z=z>>1\n num=(y|z)\n if(num>=(1<<size)):return False\n else:\n return num\ndef get_primes(n,type="int"):\n A=[True]*(n+1)\n A[0]=False\n A[1]=False\n for a in range(2,n+1):\n if A[a]:\n for b in range(a*2,n+1,a):\n A[b]=False\n if(type=="bool"):return A\n B=[]\n for a in range(n+1):\n if(A[a]):B.append(a)\n return B\ndef is_prime(num):\n if(num<=2):return False\n i=2\n while i*i<=num:\n if(num%i==0):return False\n i+=1\n return True\ndef ifelse(a,b,c):\n if a:return b\n else:return c\ndef join(A,c=""):\n n=len(A)\n A=list(map(str,A))\n s=""\n for a in range(n):\n s+=A[a]\n if(a<n-1):s+=c\n return s\ndef factorize(n,type_="dict"):\n b = 2\n list_ = []\n while b * b <= n:\n while n % b == 0:\n n //= b\n list_.append(b)\n b+=1\n if n > 1:list_.append(n)\n if type_=="dict":\n dic={}\n for a in list_:\n if a in dic:\n dic[a]+=1\n else:\n dic[a]=1\n return dic\n elif type_=="list":\n return list_\n else:\n return None\ndef floor_(n,x=1):\n return x*(n//x)\ndef ceil_(n,x=1):\n return x*((n+x-1)//x)\ndef hani(x,min_,max_):\n ret=x\n if x<min_:ret=min_\n if x>max_:ret=max_\n return ret\ndef seifu(x):\n return x//abs(x)\n###################################################\n\ndef main():\n K,N=map(int,input().split())\n A=list(map(int,input().split()))\n mmax=0\n for a in range(1,N):\n mmax=max(mmax,abs(A[a]-A[a-1]))\n print(K-mmax)\n\nmain()', '# coding: utf-8\nimport re\nimport math\nfrom collections import defaultdict\nimport itertools\nfrom copy import deepcopy\nimport random\nfrom heapq import heappop,heappush\nimport time\nimport os\nimport queue\nimport sys\nimport datetime\nfrom functools import lru_cache\n#@lru_cache(maxsize=None)\nreadline=sys.stdin.readline\nsys.setrecursionlimit(2000000)\n#import numpy as np\nalphabet="abcdefghijklmnopqrstuvwxyz"\nmod=int(10**9+7)\ninf=int(10**20)\ndef yn(b):\n if b:\n print("yes")\n else:\n print("no")\ndef Yn(b):\n if b:\n print("Yes")\n else:\n print("No")\ndef YN(b):\n if b:\n print("YES")\n else:\n print("NO")\nclass union_find():\n def __init__(self,n):\n self.n=n\n self.P=[a for a in range(N)]\n self.rank=[0]*n\n \n def find(self,x):\n if(x!=self.P[x]):self.P[x]=self.find(self.P[x])\n return self.P[x]\n \n def same(self,x,y):\n return self.find(x)==self.find(y)\n \n def link(self,x,y):\n if self.rank[x]<self.rank[y]:\n self.P[x]=y\n elif self.rank[y]<self.rank[x]:\n self.P[y]=x\n else:\n self.P[x]=y\n self.rank[y]+=1\n \n def unite(self,x,y):\n self.link(self.find(x),self.find(y))\n \n def size(self):\n S=set()\n for a in range(self.n):\n S.add(self.find(a))\n return len(S)\ndef is_power(a,b):\n now=b\n while now<a:\n now*=b\n if now==a:return True\n else:return False\ndef bin_(num,size):\n A=[0]*size\n for a in range(size):\n if (num>>(size-a-1))&1==1:\n A[a]=1\n else:\n A[a]=0\n return A\ndef get_facs(n,mod_=0):\n A=[1]*(n+1)\n for a in range(2,len(A)):\n A[a]=A[a-1]*a\n if(mod>0):A[a]%=mod_\n return A\ndef comb(n,r,mod,fac):\n if(n-r<0):return 0\n return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod\ndef next_comb(num,size):\n x=num&(-num)\n y=num+x\n z=num&(~y)\n z//=x\n z=z>>1\n num=(y|z)\n if(num>=(1<<size)):return False\n else:\n return num\ndef get_primes(n,type="int"):\n A=[True]*(n+1)\n A[0]=False\n A[1]=False\n for a in range(2,n+1):\n if A[a]:\n for b in range(a*2,n+1,a):\n A[b]=False\n if(type=="bool"):return A\n B=[]\n for a in range(n+1):\n if(A[a]):B.append(a)\n return B\ndef is_prime(num):\n if(num<=2):return False\n i=2\n while i*i<=num:\n if(num%i==0):return False\n i+=1\n return True\ndef ifelse(a,b,c):\n if a:return b\n else:return c\ndef join(A,c=""):\n n=len(A)\n A=list(map(str,A))\n s=""\n for a in range(n):\n s+=A[a]\n if(a<n-1):s+=c\n return s\ndef factorize(n,type_="dict"):\n b = 2\n list_ = []\n while b * b <= n:\n while n % b == 0:\n n //= b\n list_.append(b)\n b+=1\n if n > 1:list_.append(n)\n if type_=="dict":\n dic={}\n for a in list_:\n if a in dic:\n dic[a]+=1\n else:\n dic[a]=1\n return dic\n elif type_=="list":\n return list_\n else:\n return None\ndef floor_(n,x=1):\n return x*(n//x)\ndef ceil_(n,x=1):\n return x*((n+x-1)//x)\ndef hani(x,min_,max_):\n ret=x\n if x<min_:ret=min_\n if x>max_:ret=max_\n return ret\ndef seifu(x):\n return x//abs(x)\n###################################################\n\ndef main():\n K,N=map(int,input().split())\n A=list(map(int,input().split()))\n A.sort()\n mmax=0\n for a in range(1,N):\n mmax=max(mmax,abs(A[a]-A[a-1]))\n print(K-mmax)\n\nmain()', '# coding: utf-8\nimport re\nimport math\nfrom collections import defaultdict\nimport itertools\nfrom copy import deepcopy\nimport random\nfrom heapq import heappop,heappush\nimport time\nimport os\nimport queue\nimport sys\nimport datetime\nfrom functools import lru_cache\n#@lru_cache(maxsize=None)\nreadline=sys.stdin.readline\nsys.setrecursionlimit(2000000)\n#import numpy as np\nalphabet="abcdefghijklmnopqrstuvwxyz"\nmod=int(10**9+7)\ninf=int(10**20)\ndef yn(b):\n if b:\n print("yes")\n else:\n print("no")\ndef Yn(b):\n if b:\n print("Yes")\n else:\n print("No")\ndef YN(b):\n if b:\n print("YES")\n else:\n print("NO")\nclass union_find():\n def __init__(self,n):\n self.n=n\n self.P=[a for a in range(N)]\n self.rank=[0]*n\n \n def find(self,x):\n if(x!=self.P[x]):self.P[x]=self.find(self.P[x])\n return self.P[x]\n \n def same(self,x,y):\n return self.find(x)==self.find(y)\n \n def link(self,x,y):\n if self.rank[x]<self.rank[y]:\n self.P[x]=y\n elif self.rank[y]<self.rank[x]:\n self.P[y]=x\n else:\n self.P[x]=y\n self.rank[y]+=1\n \n def unite(self,x,y):\n self.link(self.find(x),self.find(y))\n \n def size(self):\n S=set()\n for a in range(self.n):\n S.add(self.find(a))\n return len(S)\ndef is_power(a,b):\n now=b\n while now<a:\n now*=b\n if now==a:return True\n else:return False\ndef bin_(num,size):\n A=[0]*size\n for a in range(size):\n if (num>>(size-a-1))&1==1:\n A[a]=1\n else:\n A[a]=0\n return A\ndef get_facs(n,mod_=0):\n A=[1]*(n+1)\n for a in range(2,len(A)):\n A[a]=A[a-1]*a\n if(mod>0):A[a]%=mod_\n return A\ndef comb(n,r,mod,fac):\n if(n-r<0):return 0\n return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod\ndef next_comb(num,size):\n x=num&(-num)\n y=num+x\n z=num&(~y)\n z//=x\n z=z>>1\n num=(y|z)\n if(num>=(1<<size)):return False\n else:\n return num\ndef get_primes(n,type="int"):\n A=[True]*(n+1)\n A[0]=False\n A[1]=False\n for a in range(2,n+1):\n if A[a]:\n for b in range(a*2,n+1,a):\n A[b]=False\n if(type=="bool"):return A\n B=[]\n for a in range(n+1):\n if(A[a]):B.append(a)\n return B\ndef is_prime(num):\n if(num<=2):return False\n i=2\n while i*i<=num:\n if(num%i==0):return False\n i+=1\n return True\ndef ifelse(a,b,c):\n if a:return b\n else:return c\ndef join(A,c=""):\n n=len(A)\n A=list(map(str,A))\n s=""\n for a in range(n):\n s+=A[a]\n if(a<n-1):s+=c\n return s\ndef factorize(n,type_="dict"):\n b = 2\n list_ = []\n while b * b <= n:\n while n % b == 0:\n n //= b\n list_.append(b)\n b+=1\n if n > 1:list_.append(n)\n if type_=="dict":\n dic={}\n for a in list_:\n if a in dic:\n dic[a]+=1\n else:\n dic[a]=1\n return dic\n elif type_=="list":\n return list_\n else:\n return None\ndef floor_(n,x=1):\n return x*(n//x)\ndef ceil_(n,x=1):\n return x*((n+x-1)//x)\ndef hani(x,min_,max_):\n ret=x\n if x<min_:ret=min_\n if x>max_:ret=max_\n return ret\ndef seifu(x):\n return x//abs(x)\n###################################################\n\ndef main():\n K,N=map(int,input().split())\n A=list(map(int,input().split()))\n A.sort()\n mmax=0\n for a in range(0,N):\n mmax=max(mmax,abs(A[(a+1)%N]+K*((a+1)//N)-A[a]))\n print(K-mmax)\n\nmain()']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s239558020', 's879554717', 's200423719']
[26700.0, 26700.0, 26700.0]
[135.0, 136.0, 162.0]
[3589, 3602, 3619]
p02725
u903005414
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
["import numpy as np\nK, N = map(int, input().split())\nA = np.array(list(map(int, input().split())))\ndiff = A[1:] - A[:-1]\ndiff = np.append(diff, K + A[0] - A[-1])\nprint('diff', diff)\nans = diff.sum() - diff.max()\nprint(ans)\n", "import numpy as np\nK, N = map(int, input().split())\nA = np.array(list(map(int, input().split())))\ndiff = A[1:] - A[:-1]\ndiff = np.append(diff, K + A[0] - A[-1])\n# print('diff', diff)\nans = diff.sum() - diff.max()\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s501926422', 's148918506']
[34160.0, 35824.0]
[215.0, 214.0]
[222, 224]
p02725
u904331908
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int,input().split())\n\nAi = list(map(int,input().split()))\nkyori = []\n\nfor x in range(n-1):\n kyori.append(Ai[x+1]-Ai[x])\n \nkyori.append(Ai[0]+k-Ai[n-1])\n\nkyoto.remove(max(kyori))\n\nprint(sum(kyori))\n', 'k,n = map(int,input().split())\n\nAi = list(map(int,input().split()))\nkyori = []\n\nfor x in range(n-1):\n kyori.append(Ai[x+1]-Ai[x])\n \nkyori.append(Ai[0]+k-Ai[n-1])\n\nkyori.remove(max(kyori))\n\nprint(sum(kyori))\n']
['Runtime Error', 'Accepted']
['s410892156', 's020919525']
[32336.0, 32352.0]
[102.0, 112.0]
[209, 209]
p02725
u904547029
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\ndistence_list = [x for x in [ A[i+1] - A[i] for i in range(len(A)-1)]]\n\nm = max(distence_list)\n\nprint(K-m)\n', 'K,N = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\ndistence_list = [x for x in [ A[i+1] - A[i] for i in range(len(A)-1)]]\n\nm = max(distence_list)\n\nx = K - A[-1] + A[0]\n\nif m > x:\n print(K-m)\nelse:\n print(A[-1] - A[0])\n']
['Wrong Answer', 'Accepted']
['s701878813', 's177133339']
[26420.0, 25920.0]
[107.0, 104.0]
[180, 242]
p02725
u906501980
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['def main():\n x, y = map(int, input().split())\n a = list(map(int, input().split()))\n cost = 10*10\n for i in range(n-1):\n cost = min(cost, k - abs(a[i]-a[i+1]))\n print(min(cost, k-abs(a[0]+k-a[n-1])))\n\nif __name__ == "__main__":\n main()', 'def main():\n k, n = map(int, input().split())\n a = list(map(int, input().split()))\n cost = a[n-1]-a[0]\n for i in range(n-1):\n cost = min(cost, k-(a[i+1]-a[i]))\n print(cost)\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s646101182', 's697790547']
[26444.0, 25836.0]
[65.0, 142.0]
[259, 233]
p02725
u907414670
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = input().split()\na_list_org = list(map(int,input().split()))\na_list_org.sort()\na_list = [a - int(k) if (a > int(k) // 2) else a for a in a_list_org]\na_list.sort()\nprint(a_list)\nans1 = 0\nans2 = 0\nfor a in a_list:\n if a == a_list[0]:\n pre = a\n continue\n else:\n ans1 += (a - pre)\n pre = a\nfor a in a_list_org:\n if a == a_list_org[0]:\n pre = a\n continue\n else:\n ans2 += (a - pre)\n pre = a\nans = min(ans1, ans2)\nprint(ans)', 'k, n = input().split()\na_list_org = list(map(int,input().split()))\na_list = []\nfor a in a_list_org:\n if a == a_list_org[0]:\n pre = a\n a_list.append(int(k) - a_list_org[-1] + a)\n else:\n a_list.append(a - pre)\n pre = a\na_list.remove(max(a_list))\nprint(sum(a_list))']
['Wrong Answer', 'Accepted']
['s799908574', 's602437491']
[26444.0, 26444.0]
[273.0, 124.0]
[491, 296]
p02725
u907446975
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['(n,m)=map(int,input().split())\na=input().split()\na=list(map(int,a))\nl=[]\nk=0\na=sorted(a)\nfor i in range(m-1):\n d=abs(a[i]-a[i+1])\n k=k+d\n l.append(d)\n# k=k-d\nc=n-k\nprint(c)\nl=sorted(l)\nl1=sum(l)\nprint(l1-l[-1])', '(n,m)=map(int,input().split())\na=input().split()\na=list(map(int,a))\nl=[]\nk=0\na=sorted(a)\nfor i in range(m-1):\n d=abs(a[i]-a[i+1])\n k=k+d\n l.append(d)\n# k=k-d\nc=n-k\nl.append(c)\nl=sorted(l)\nl1=sum(l)\nprint(l1-l[-1])']
['Wrong Answer', 'Accepted']
['s566701127', 's523651097']
[25840.0, 26444.0]
[189.0, 183.0]
[219, 222]
p02725
u910632349
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input().split())\na=list(map(int,input().split()))\nb=[]\nfor i in range(n-1):\n b.append(a[i+1]-a[i])\nb.append((k-a[n-1])+a[0])\nprint(b)\nprint(k-max(b))', 'k,n=map(int,input().split())\na=list(map(int,input().split()))\nb=[]\nfor i in range(n-1):\n b.append(a[i+1]-a[i])\nb.append((k-a[n-1])+a[0])\nprint(k-max(b))']
['Wrong Answer', 'Accepted']
['s522495465', 's226176172']
[32328.0, 32304.0]
[121.0, 111.0]
[164, 155]
p02725
u914330401
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['#include <bits/stdc++.h>\nusing namespace std;\n\nint main()\n{\n int64_t n, k;\n cin >> k >> n;\n vector<int64_t> li(n * 2);\n for (int i = 0; i < n; ++i)\n {\n cin >> li[i];\n li[i + n] = li[i] - k;\n }\n sort(li.begin(), li.end());\n int64_t ans = 10e9;\n for (int i = 0; i < 2 * n - (n - 1); ++i)\n ans = min(ans, abs(li[i] - li[i + n - 1]));\n cout << ans << "\\n";\n}', 'k, n = map(int, input().split())\nli = list(map(int, input().split()))\n\ntmp = [0] * n\nfor i in range(n):\n tmp[i] = li[i] - k\nli = li + tmp\nli.sort()\nans = 10**9\nfor i in range(len(li) - n+1):\n ans = min(ans, abs(li[i] - li[i + n-1]))\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s977330591', 's746395789']
[2940.0, 26436.0]
[19.0, 216.0]
[373, 250]
p02725
u919017918
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\n\nhouse_list = list(map(int, input().split()))\nprint(house_list)\n\n\nif 0 in house_list:\n print(min(house_list[-1] - house_list[1], house_list[-1] - house_list[0]))\nelse:\n print(min(house_list[-1] - house_list[1]))', 'K, N = map(int, input().split())\n\nhouse_list = list(map(int, input().split()))\n#print(house_list)\n\n\nif 0 in house_list:\n print(min(house_list[-1] - house_list[1], house_list[-1] - house_list[0]))\nelse:\n print(min(house_list[-1] - house_list[1]))', 'K, N = map(int, input().split())\n\nhouse_list = list(map(int, input().split()))\n#print(house_list)\n\n\nif 0 in house_list:\n print(min(house_list[-1] - house_list[1], house_list[-1] - house_list[0]))\nelse:\n print(min(house_list[-1] - house_list[0]))', 'K, N = map(int, input().split())\n\nhouse_list = list(map(int, input().split()))\n#print(house_list)\n\ndist_list = [K - house_list[-1] + house_list[0]]\n#print(dist_list)\n\nfor n in range(1, N):\n dist_list.append(house_list[n] - house_list[n-1])\nprint(K - max(dist_list))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s489019481', 's559243100', 's880724074', 's093891764']
[26444.0, 26444.0, 25804.0, 25840.0]
[90.0, 72.0, 67.0, 116.0]
[250, 251, 251, 268]
p02725
u920604133
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int, input().split())\n\na = [ int (x) for x in input().split() ]\n\nkyori_sa = []\n\nprint(len(a)-1)\n\n\nfor i in range(n):\n if i == len(a)-1:\n kyori_sa.append(a[0] - ( k - a[i] ))\n else:\n kyori_sa.append(a[i+1] - a[i])\n\nprint(k-max(kyori_sa))', 'k,n = map(int, input().split())\n\na = [ int (x) for x in input().split() ]\n\nkyori_sa = []\n\nfor i in range(n):\n if i == len(a)-1:\n kyori_sa.append(a[0] + ( k - a[i] ))\n else:\n kyori_sa.append(a[i+1] - a[i])\n\nprint(k-max(kyori_sa))\n ']
['Wrong Answer', 'Accepted']
['s720155903', 's424687511']
[26444.0, 25452.0]
[147.0, 148.0]
[254, 242]
p02725
u922769680
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N=map(int,input().split())\na_list=list(map(int,input().split()))\nb_list=[]\nfor i in range(N-1):\n X=a_list[i+1]-a_list[i]\n b_list.append(abs(X))\nb_list.append(K-a_list[-1]+a_list[0])\nprint(b_list)\nprint(K-max(b_list))', 'K,N=map(int,input().split())\na_list=list(map(int,input().split()))\nb_list=[]\nfor i in range(N-1):\n X=a_list[i+1]-a_list[i]\n b_list.append(abs(X))\nb_list.append(K-a_list[-1]+a_list[0])\nprint(K-max(b_list))']
['Wrong Answer', 'Accepted']
['s151537658', 's362717831']
[25840.0, 25452.0]
[144.0, 131.0]
[224, 210]
p02725
u924717835
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int,input().split())\na = list(map(int,input().split()))\nx = [a[0]-a[-1]+K]\nfor i in range(1,N):\n x.append(a[i]-a[i-1])\nprint(x)\nprint(K-max(x))', 'K, N = map(int,input().split())\na = list(map(int,input().split()))\nx = [a[0]-a[-1]+K]\nfor i in range(1,N):\n x.append(a[i]-a[i-1])\nprint(K-max(x))']
['Wrong Answer', 'Accepted']
['s999096626', 's385490247']
[26444.0, 26444.0]
[131.0, 121.0]
[157, 148]
p02725
u927839462
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['kn=list(map(int, input().split()))\na=list(map(int, input().split()))\nk=kn[0]\nn=kn[1]\nmaxdis=a[n-1]+a[0]\nfor i in range(n-1):\n if maxdis<(a[i+1]-a[i]):\n maxdis=(a[i+1]-a[i])\nprint(k-maxdis)', 'kn=list(map(int, input().split()))\na=list(map(int, input().split()))\nk=kn[0]\nn=kn[1]\nmaxdis=k-a[n-1]+a[0]\n#print(maxdis)\nfor i in range(n-1):\n if maxdis<(a[i+1]-a[i]):\n maxdis=(a[i+1]-a[i])\n #print(i)\n #print(maxdis)\nprint(k-maxdis)']
['Wrong Answer', 'Accepted']
['s366690099', 's846491724']
[26444.0, 26444.0]
[102.0, 106.0]
[198, 256]
p02725
u931173291
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['e = list(map(int,input().split()))\nK = e[0]\nN = e[1]\na = list(map(int,input().split()))\nc = [a[i+1] - a[i] for i in range(N-1)]\nf = a[0]+20 - a[N-1]\nc.append(f)\nd = max(c)\nprint(c)\nprint(d)\nprint(K - d)\n', 'K,N = map(int,input().split())\na = list(map(int,input().split()))\nc = a[1:]-a[:-1]\nd = max(c)\nprint(K - d)\n', 'e = list(map(int,input().split()))\nK = e[0]\nN = e[1]\na = list(map(int,input().split()))\nc = [a[i+1] - a[i] for i in range(N-1)]\nf = a[0]+ K - a[N-1]\nc.append(f)\nd = max(c)\nprint(K - d)\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s084287712', 's251828440', 's262011178']
[25840.0, 26444.0, 26444.0]
[113.0, 70.0, 107.0]
[203, 107, 185]
p02725
u932868243
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input().split())\nlista=list(map(int,input().split())) \nlista.append(lista[0]+k)\nans=[]\nfor i in range(1,n):\n ans.append(lista[i]-lista[i-1])\nprint(k-max(ans))', 'k,n=map(int,input().split())\nlista=list(map(int,input().split())) \nans=[]\nfor i in range(n-1):\n ans.append(lista[i+1]-lista[i])\nprint(k-max(ans))', 'k,n=map(int,input().split())\na=list(map(int,input().split()))\na.append(k+a[0])\nprint(k-max(a))\n ', 'k,n=map(int,input().split())\nlista=list(map(int,input().split())) \nans=[]\nfor i in range(1,n):\n ans.append(lista[i]-lista[i-1])\nprint(k-max(ans))', 'k,n=map(int,input().split())\na=list(map(int,input().split()))\na.append(k+a[0])\nb=[]\nfor i in range(1,n+1):\n b.append(a[i]-a[i-1])\nprint(k-max(b))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s327851910', 's417658731', 's724993008', 's792369295', 's127688924']
[26444.0, 26444.0, 26444.0, 26420.0, 26420.0]
[124.0, 116.0, 75.0, 119.0, 118.0]
[171, 146, 102, 146, 146]
p02725
u934053315
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['m, n = map(int, input().split())\nnums = list(map(int, input().split()))\n\na = 0\nfor i in range(n):\n if i == n-1:\n dif = m - nums[i]\n else:\n dif = nums[i+1] - nums[i]\n a = max(a, dif)\n \nprint(m-a)\n\n', 'm, n = map(int, input().split())\nnums = list(map(int, input().split()))\n \na = 0\nfor i in range(n):\n if i == n-1:\n dif = m + nums[0] - nums[i]\n else:\n dif = nums[i+1] - nums[i]\n a = max(a, dif)\n\nprint(m-a)']
['Wrong Answer', 'Accepted']
['s731984286', 's956594634']
[25836.0, 26436.0]
[164.0, 175.0]
[206, 213]
p02725
u934868410
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int,input().split())\na = list(map(int,input().split()))\nans = a[n-1] + a[0]\nfor i in range(n-1):\n ans = min(ans, k - a[i+1] + a[i])\nprint(ans)', 'k,n = map(int,input().split())\na = list(map(int,input().split()))\nans = k - a[n-1] + a[0]\nfor i in range(n-1):\n ans = min(ans, a[i+1] - a[i])\nprint(ans)', 'k,n = map(int,input().split())\na = list(map(int,input().split()))\nans = a[n-1] - a[0]\nfor i in range(n-1):\n ans = min(ans, k - a[i+1] + a[i])\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s362200019', 's683468675', 's796591838']
[26436.0, 26436.0, 26420.0]
[153.0, 147.0, 146.0]
[153, 153, 153]
p02725
u935558307
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = map(int,input().split())\nA = list(map(int,input().split()))\n\nfoK,N = map(int,input().split())\nA = list(map(int,input().split()))\nans = []\n\nfor i in range(N-1):\n now = i\n pre = now-1\n post = now +1\n \n if now == 0:\n preDic = (K-A[N-1])+A[now]\n else:\n preDic = A[now]-A[pre]\n postDic = A[post]-A[now] \n if preDic >= postDic:\n ans.append(K-preDic)\n else:\n ans.append(K-postDic)\n\n \nprint(min(ans))', 'K,N = map(int,input().split())\nA = list(map(int,input().split()))\nans = []\n\nfor i in range(N-1):\n now = i\n pre = now-1\n post = now +1\n \n if now == 0:\n preDic = (K-A[N-1])+A[now]\n else:\n preDic = A[now]-A[pre]\n postDic = A[post]-A[now] \n if preDic >= postDic:\n ans.append(K-preDic)\n else:\n ans.append(K-postDic)\n \nprint(min(ans))']
['Runtime Error', 'Accepted']
['s426024940', 's162794281']
[26444.0, 26444.0]
[69.0, 214.0]
[497, 425]
p02725
u936378263
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\ndist = [0] * (N-1)\n\nfor i in range(N-1):\n dist[i] = A[i+1] - A[i]\n \nprint(K - max(dist))', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\ninv_ans = 0\n\nfor i in range(N-1):\n if inv_ans < A[i+1] - A[i]:\n inv_ans = A[i+1] - A[i]\n\nprint(K - inv_ans)', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\ndist = [0] * (N)\n\nfor i in range(N-1):\n dist[i] = A[i+1] - A[i]\ndist[N-1] = A[0] - A[-1] + K\n\nprint(K - max(dist))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s137781420', 's283298922', 's768075495']
[25840.0, 25840.0, 26444.0]
[112.0, 104.0, 111.0]
[162, 181, 185]
p02725
u936735179
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = list(map(int,input().split()))\na = list(map(int,input().split()))\nmax_d = 0\nfor idx, i in enumerate(a):\n if idx == n - 1:\n if max_d < n - a[-1] + a[0]:\n max_d = n - a[-1] + a[0]\n else:\n if max_d < a[idx + 1] - i:\n max_d = a[idx + 1] - i\nprint(k - max_d)', 'k, n = list(map(int,input().split()))\na = list(map(int,input().split()))\nmax_d = 0\na.append(a[0] + k)\nprint(a)\nfor idx, i in enumerate(a[:-1]):\n if max_d < a[idx + 1] - i:\n max_d = a[idx + 1] - i\n \nprint(k - max_d)', 'k, n = list(map(int,input().split()))\na = list(map(int,input().split()))\nmax_d = 0\na.append(a[0] + k)\nfor idx, i in enumerate(a[:-1]):\n if max_d < a[idx + 1] - i:\n max_d = a[idx + 1] - i\nprint(k - max_d)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s055977152', 's643523610', 's109977834']
[26444.0, 26444.0, 26444.0]
[121.0, 124.0, 105.0]
[302, 227, 213]
p02725
u938256038
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\n\nK, N = map(int, input().split())\nA = [int(x) for x in input().split()]\nA.append(K)\n\ndiff_A = []\nfor i in range(N):\n diff_A.append(A[i+1] - A[i])\ndiff_max = max(diff_A)\nprint(K - diff_max)', 'import numpy as np\n\nK, N = map(int, input().split())\nA = [int(x) for x in input().split()]\n\ndiff_A = []\nfor i in range(N-1):\n diff_A.append(A[i+1] - A[i])\ndiff_max = max(diff_A)\nprint(K - diff_max)', 'import numpy as np\n\nK, N = map(int, input().split())\nA = [int(x) for x in input().split()]\nA.append(K+A[0])\n\ndiff_A = []\nfor i in range(N):\n diff_A.append(A[i+1] - A[i])\ndiff_max = max(diff_A)\nprint(K - diff_max)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s572146966', 's970802446', 's281901091']
[35096.0, 35096.0, 35136.0]
[255.0, 254.0, 254.0]
[210, 200, 215]
p02725
u941022948
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int, input().split())\na=[0]*n\na=list(map(int, input().split()))\nfor i in range(n):\n if a[i]>(k+0.5)//2:\n a[i]=int((k+0.5)//2)-a[i]\nla=sorted(a)\nprint(max(a)-la[0])', 'k, n = map(int, input().split())\na=[0]*n\na=list(map(int, input().split()))\nfor i in range(n):\n if a[i]>k/2:\n a[i]=k/2-a[i]\nla=sorted(a)\nprint(int(max(a)-la[0]))', 'k,n=map(int,input().split())\na=list(map(int,input().split()))\nb=[0]*2\nb[0]=max(a)-min(a)\na.sort()\nb[1]=a[-1]-a[-2]\nprint(min(b))', 'k, n = map(int, input().split())\na=[0]*n\na=list(map(int, input().split()))\nif (n==3)or(n==2):\n for i in range(n):\n if a[i]>(k+0.5)//2:\n a[i]=int((k+0.5)//2)-a[i]\nla=sorted(a)\nprint(max(a)-la[0])', 'a,b=map(int,input().split())\nlist1=list(map(int,input().split()))\nlist1.sort()\nlist2=[]\nfor i in range(b-1):\n list2.append(list1[i+1]-list1[i])\nlist2.append(list1[0]+a-list1[-1])\nlist2.sort()\nans=[list1[-1]-list1[0],a-max(list2)]\nprint(min(ans))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s066513360', 's301346714', 's534220969', 's614163109', 's644125021']
[27116.0, 27980.0, 25928.0, 27956.0, 26100.0]
[236.0, 147.0, 76.0, 75.0, 148.0]
[184, 170, 128, 215, 248]
p02725
u942144900
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import sys\nread = sys.stdin.buffer.read\n \nK, N, *A = map(int, read().split())\nA.append([A[0] + K])\ngap = max(y - x for x, y in zip(A, A[1:]))\nprint(K - gap)', 'import sys\nread = sys.stdin.buffer.read\n \nK, N, *A = map(int, read().split())\nA.append(A[0] + K)\ngap = max(y - x for x, y in zip(A, A[1:]))\nprint(K - gap)']
['Runtime Error', 'Accepted']
['s809226869', 's757653818']
[20348.0, 20348.0]
[80.0, 78.0]
[156, 154]
p02725
u944643608
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\nK, N = map(int, input().split())\nA = list(map(int, input().split()))\nA = np.array(A)\nma = 0\nfor i in range(N-1):\n tmp = abs(A[i] -A[i+1])\n if min(tmp,K - tmp) > ma:\n ma = min(tmp,K-tmp)\nprint(K - ma)\n ', 'import numpy as np\nK, N = map(int, input().split())\nA = list(map(int, input().split()))\nA = np.array(A)\nma = 0\nfor i in range(N-1):\n if A[i+1] - A[i] > ma:\n ma = A[i+1] -A[i]\nif K -(A[N-1] -A[0]) > ma:\n ma = K -(A[N-1] -A[0])\nprint(K -ma)\n']
['Wrong Answer', 'Accepted']
['s978419196', 's822780128']
[43056.0, 42844.0]
[1528.0, 1962.0]
[228, 244]
p02725
u945157177
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int, input().split())\nl_1 = [int(x) for x in input().split()]\nl_2 = []\nfor i in range(n-1):\n dis = l_1[i+1]-l_1[i]\n l_2.append(dis)\ndis = k-l_1[n-1]+l_1[0]\nl_2.append(dis)\nprint(l_2)\nans = k-max(l_2)\nprint(ans)', 'k,n = map(int, input().split())\nl_1 = [int(x) for x in input().split()]\nl_2 = []\nfor i in range(n-1):\n dis = l_1[i+1]-l_1[i]\n l_2.append(dis)\ndis = k-l_1[n-1]+l_1[0]\nl_2.append(dis)\n#print(l_2)\nans = k-max(l_2)\nprint(ans)']
['Wrong Answer', 'Accepted']
['s838994396', 's981246504']
[26444.0, 24948.0]
[145.0, 129.0]
[226, 227]
p02725
u949115942
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int, input().split())\n\nAn = list(map(int, input().split()))\n\nAnk = [0] + An[:] + [k]\n\nnode = [Ank[i+1] - Ank[i] for i in range(len(Ank) - 1)]\n\nprint(sum(node) - max(node))', 'k, n = map(int, input().split())\n\nAn = list(map(int, input().split()))\n\ndef cal(An):\n if len(An) == 1:\n print(An[0])\n else:\n Ank = [0] + An[:] + [k]\n \n node = [Ank[i+1] - Ank[i] for i in range(len(Ank) - 1)]\n print(sum(node) - max(node))\n \ncal(An)', 'k, n = map(int, input().split())\n \nAn = list(map(int, input().split()))\n \nnode = [An[i+1] - An[i] for i in range(len(An) - 1)]\n \nnode = node[:] + [k - An[n-1] + An[0]]\n \nprint(k - max(node))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s253237420', 's679645149', 's605921833']
[25840.0, 26420.0, 26444.0]
[103.0, 94.0, 102.0]
[183, 292, 191]
p02725
u951425592
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int,input().split())\nA = list(map(int,input().split()))\n#A = list(map(int,input().split()))\n\nhalf = k/2\nans = 0\nfor i in range(n):\n if A[i] >= half:\n ans += A[i] - half\n else:\n ans += A[i]\nprint(ans)\n\n', 'k,n = map(int,input().split())\nA = list(map(int,input().split()))\n#A = list(map(int,input().split()))\n\nC = []\n\nfor i,v in enumerate(A):\n if i <= len(A) - 2:\n C.append(A[i+1] - A[i])\n else: \n C.append(k - A[i] + A[0])\n\nmaxwidth = max(C)\nprint(k-maxwidth) \n\n']
['Wrong Answer', 'Accepted']
['s637571577', 's865587267']
[26436.0, 26444.0]
[141.0, 151.0]
[219, 360]
p02725
u954489496
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['from sys import stdin, stdout \n\nn = stdin.readline() \narr = [int(x) for x in stdin.readline().split()] \nK=arr[0]\nN=arr[1]\nn = stdin.readline() \nA = [int(x) for x in stdin.readline().split()] \ndist=[]\nfor i in range(0,N-1):\n dist.append(A[i+1]-A[i])\ndist.append(abs(A[0]-A[-1]+K))\n\nm=max(dist)\nfor idx,val in enumerate(dist):\n if(val==m):\n dist[idx]=0\n break\nprint(sum(dist))', 'from sys import stdin, stdout \n\nK, N = [int(c) for c in input().split()]\nA = [int(c) for c in input().split()]\ndist=[]\nfor i in range(0,N-1):\n dist.append(A[i+1]-A[i])\ndist.append(abs(A[0]-A[-1]+K))\n\nm=max(dist)\nfor idx,val in enumerate(dist):\n if(val==m):\n dist[idx]=0\n break\nprint(sum(dist))']
['Runtime Error', 'Accepted']
['s015781804', 's941542174']
[24908.0, 26444.0]
[76.0, 143.0]
[395, 314]
p02725
u957098479
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = map(int,input().split())\nA = list(map(int,input().split()\n\nX = A[1] - A[0]\ni = 1\nwhile i < N-1:\n Y = A[i+1] - A[i]\n if X < Y:\n X = Y\n i += 1\nZ = A[0] + K - A[N-1]\nif X < Z:\n X = Z\n\nprint(K - X)', 'K,N = map(int,input().split())\nA = list(map(int,input().split()))\n\nX = A[1] - A[0]\ni = 1\nwhile i < N-1:\n Y = A[i+1] - A[i]\n if X < Y:\n X = Y\n i += 1\nZ = A[0] + K - A[N-1]\nif X < Z:\n X = Z\n\nprint(K - X)']
['Runtime Error', 'Accepted']
['s795959202', 's132989336']
[2940.0, 26444.0]
[17.0, 142.0]
[218, 220]
p02725
u964904181
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nA2 = [K+a for a in A]\n\nA = A + A2\nprint(A)\ndist1 = A[N-1] - A[0]\ndist2 = A[2*N-2] - A[N-1]\n\nprint(min(dist1, dist2))\n', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nA3 = A + [K+a for a in A]\ndist = [A3[i+N-1] - A[i] for i in range(N)]\n\nprint(min(dist))\n\n']
['Wrong Answer', 'Accepted']
['s746115968', 's146442508']
[35212.0, 34752.0]
[122.0, 122.0]
[187, 159]
p02725
u966542724
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['kn = input().split()\na = input().split()\n\nal = [int(i) for i in a]\nk = int(kn[0])\nn = kn[1]\n\nml = 20 - abs(al[len(al)-1] - al[0])\nprint(ml)\n\nfor i in range(len(al)):\n\tif i == 0:\n\t\tml = max(ml, abs(al[0]-al[1]))\n\t\t# print(abs(al[0])-al[len(al)-1])\n\telif i == len(al)-1:\n\t\t1 == 1\n\t\t\n\telse:\n\n\t\tml = max(ml,(al[i-1]-al[i]),abs(al[i]-(al[i+1])))\n\n\t\tprint(abs(al[len(al)-1]-(al[i+1])))\n\n\nprint(k-ml)\n\n', 'kn = input().split()\na = input().split()\n\nal = [int(i) for i in a]\nk = int(kn[0])\nn = kn[1]\n\nml = k - abs(al[len(al)-1] - al[0])\n\n\nfor i in range(len(al)-1):\n\tml = max(ml,abs(al[i]-(al[i+1])))\n\n\nprint(k-ml)\n\n']
['Wrong Answer', 'Accepted']
['s132764161', 's572855423']
[27852.0, 24948.0]
[451.0, 169.0]
[431, 208]
p02725
u967835038
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input().split())\na=[]\na=list(map(int,input().split()))\ndis=[]\ndis.append(a[0]+(k-a[n-1]))\nfor i in range(n-1):\n dis.append(a[i+1]-a[i])\nprint(min(dis))', 'k,n=map(int,input().split())\na=[]\na=list(map(int,input().split()))\ndis=[]\ndis.append(a[0]+(k-a[n-1]))\nfor i in range(n-1):\n dis.append(a[i+1]-a[i])\nprint(k-max(dis))\n']
['Wrong Answer', 'Accepted']
['s198039479', 's673726332']
[25840.0, 26444.0]
[116.0, 117.0]
[166, 169]
p02725
u968404618
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['from itertools import accumulate\nimport sys\ninput=lambda :sys.stdin.readline().rstrip()\n\nk, n = map(int, input().split())\nA = list(map(int, input().split()))\n\nS = [0] + list(accumulate(A))\nd = [S[i] - S[i - k] for i in range(k, n + 1)]\nprint(d)', 'k, n = map(int, input().split())\nA = list(map(int, input().split()))\nA.append(A[0]+k)\n\nl = 0\nfor i in range(n):\n l = max(l, A[i+1]-A[i])\nans = k - l\nprint(ans)']
['Wrong Answer', 'Accepted']
['s532407503', 's226838891']
[25840.0, 32280.0]
[80.0, 128.0]
[244, 162]
p02725
u968649733
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = [int(n) for n in input().split()]\nA = [int(n) for n in input().split()]\n\nmin_dis = K+1\n\nfor i in range(len(A) -1):\n dis = A[i+1] - A[i]\n if dis < min_dis:\n ans = (i+1)+1\n min_dis = dis\nprint(ans)', 'K, N = [int(n) for n in input().split()]\nA = [int(n) for n in input().split()]\n\nmax_dis = 0\ntotal_dis = 0\nfor i in range(len(A)):\n if i == len(A)-1:\n \tdis = A[0] + (K - A[i])\n else:\n \tdis = A[i+1] - A[i]\n total_dis +=dis\n if dis > max_dis:\n max_dis = dis\nprint(total_dis - max_dis)']
['Wrong Answer', 'Accepted']
['s526376465', 's285452470']
[26420.0, 26444.0]
[118.0, 169.0]
[223, 303]
p02725
u968846084
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n=map(int,input().split())\nA=list(map(int,input().split()))\nans=A[0]-A[-1]+n\nfor i in range(n-1):\n a=A[i+1]-A[i]\n if a>ans:\n ans=a\nprint(k-a)', 'k,n=map(int,input().split())\nA=list(map(int,input().split()))\nans=A[0]-A[-1]+n\nfor i in range(n-1):\n a=A[i+1]-A[i]\n if a>ans:\n ans=a\nprint(k-ans)', 'k,n=map(int,input().split())\nA=list(map(int,input().split()))\nans=A[0]-A[-1]+k\nfor i in range(n-1):\n a=A[i+1]-A[i]\n if a>ans:\n ans=a\nprint(k-ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s278747028', 's866141318', 's187212469']
[26444.0, 26420.0, 26436.0]
[108.0, 110.0, 114.0]
[148, 150, 151]
p02725
u969211566
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k,n = map(int,input().split())\na = list(map(int,input().split()))\nb = [0]*n\na.sort()\namin = a[n-1] - a[0]\nfor i in range(n):\n if a[i] < k//2:\n b[i] = a[i] + k\n else:\n b[i] = a[i]\nb.sort()\nbmin = b[n-1] - b[0]\nprint(a,b)\nprint(min(amin,bmin))', 'k,n = map(int,input().split())\na = list(map(int,input().split()))\n \nsum = a[0] - a[-1] + k\nfor i in range(1, n):\n sum = max(sum,a[i] - a[i - 1])\n \nprint(k - sum)']
['Wrong Answer', 'Accepted']
['s211728631', 's797359797']
[26444.0, 25452.0]
[165.0, 137.0]
[249, 164]
p02725
u970133396
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['import numpy as np\nK, N = map(int, input().strip().split())\nA = list(map(int, input().strip().split()))\n\n# min_=10**6\ndA=np.diff(A)\nnp.append(dA,A[0]+K-A[-1])\nskip_dist=np.max(dA)\nans=K-skip_dist\n\nprint(ans)', 'import numpy as np\nK, N = map(int, input().strip().split())\nA = list(map(int, input().strip().split()))\n\nmin_=10**6\ndA=np.diff(A)\nnp.append(dA,abs(A[0]-A[-1]))\nskip_dist=max(dA)\nans=K-skip_dist\n\nprint(ans)', 'import numpy as np\nK, N = map(int, input().strip().split())\nA = list(map(int, input().strip().split()))\n\n# min_=10**6\ndA=np.diff(A)\nnp.append(dA,A[0]+K-A[-1])\nskip_dist=max(dA)\nans=K-skip_dist\n\nprint(ans)', 'import numpy as np\nK, N = map(int, input().strip().split())\nA = list(map(int, input().strip().split()))\n\n# min_=10**6\ndA=np.diff(A)\ndA=np.append(dA,A[0]+K-A[-1])\nskip_dist=max(dA)\nans=K-skip_dist\n\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s149200482', 's318265552', 's744910786', 's470299303']
[34152.0, 42428.0, 35780.0, 34160.0]
[219.0, 1195.0, 239.0, 232.0]
[207, 205, 204, 207]
p02725
u975039852
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['k, n = map(int, input().split())\na = list(map(int, input().split()))\na.append(k - sum(a))\nprint(k - max(a))', 'k, n = map(int, input().split())\na = list(map(int, input().split()))\nd = [a[i+1] - a[i] for i in range(n-1)]\nd.append(k + a[0] - a[-1])\nprint(k - max(d))\n']
['Wrong Answer', 'Accepted']
['s549677444', 's458586686']
[26444.0, 26444.0]
[70.0, 100.0]
[107, 154]
p02725
u975820355
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['X = int(input())\n\na = int(X / 500)*1000 + int((X%500)/5)*5\nprint(a)\n', 'K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nmax = A[0] + (K - A[-1])\nfor i in range(len(A)-1):\n d = A[i+1] - A[i]\n if d > max:\n max = d\nprint(K-max)']
['Runtime Error', 'Accepted']
['s839513339', 's137162548']
[2940.0, 26444.0]
[17.0, 112.0]
[68, 179]
p02725
u981864683
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K,N = map(int,input().split())\nA = list(map(int,input().split()))\n\ndiff = []\n\n\nfor i in range(N-1):\n Diff = A[i+1] -A[i]\n diff.append(Diff)\n \ndiff.append(K-A[N-1]-A[0])\n\n\nDIFF = sorted(diff)\nprint(DIFF)\nif A[0] == 0:\n del DIFF[-1]\n\nprint(sum(DIFF))', 'K,N = map(int,input().split())\nA = list(map(int,input().split()))\n\ndiff = []\n\n\nfor i in range(N-1):\n Diff = A[i+1] -A[i]\n diff.append(Diff)\n \ndiff.append(K-A[N-1]+A[0])\n\n\nDIFF = sorted(diff)\nprint(DIFF)\n\ndel DIFF[-1]\n\nprint(sum(DIFF))', 'K,N = map(int,input().split())\nA = list(map(int,input().split()))\n\ndiff = []\n\n\nfor i in range(N-1):\n Diff = A[i+1] -A[i]\n diff.append(Diff)\n \ndiff.append(K-A[N-1]+A[0])\n\n\nDIFF = sorted(diff)\n\ndel DIFF[-1]\n\nprint(sum(DIFF))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s338199199', 's993015223', 's896631982']
[25840.0, 26444.0, 26444.0]
[160.0, 163.0, 148.0]
[260, 243, 231]
p02725
u985374340
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['K, N = list(map(int, input().split()))\nA = [0] * N\nA = list(map(int, input().split()))\n\nsorted_A = sorted(A)\nsorted_A = [i - sorted_A[0] for i in sorted_A]\n\nprint(sorted_A)\n\ndis = []\nfor i in range(len(sorted_A)-1):\n dis.append(abs(sorted_A[i] - sorted_A[i+1]))\n\nlast_dis = abs(sorted_A[-1] - sorted_A[0])\n\nif(last_dis >= K/2):\n last_dis = K - last_dis\n\ndis.append(last_dis)\n\nprint(K - max(dis))', 'K, N = list(map(int, input().split()))\nA = [0] * N\nA = list(map(int, input().split()))\n\nsorted_A = sorted(A)\nsorted_A = [i - sorted_A[0] for i in sorted_A]\n\ndis = []\nfor i in range(len(sorted_A)-1):\n dis.append(abs(sorted_A[i] - sorted_A[i+1]))\n\nlast_dis = abs(sorted_A[-1] - sorted_A[0])\n\nif(last_dis >= K/2):\n last_dis = K - last_dis\n\ndis.append(last_dis)\n\nprint(K - max(dis))']
['Wrong Answer', 'Accepted']
['s053774746', 's448893552']
[27980.0, 27980.0]
[163.0, 149.0]
[401, 384]
p02725
u987326700
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
['round,house_num = map(int,input().split())\n\ndistance = list(map(int,input().split()))\n\nmin = distance[-1] - distance[0]\n\nfor i in range(house_num - 1):\n if round-(distance[i+1]-distance[i]) < min:\n min = round-(distance[i+1]-distance[i])\n print(min)', 'n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nlis = []\nfor i in range(k-1):\n lis.append(a[i+1]-a[i])\nlis.append(a[0]-a[-1]+n)\nprint(sum(lis)-max(lis))']
['Wrong Answer', 'Accepted']
['s564549489', 's606141319']
[26060.0, 26420.0]
[267.0, 119.0]
[254, 172]
p02725
u991269553
2,000
1,048,576
There is a circular pond with a perimeter of K meters, and N houses around them. The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond. When traveling between these houses, you can only go around the pond. Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
["k,n = map(int,input().split())\na = list(map(int,input().split()))\n\n#print(a)\nsa = []\nfor i in range(1,n):\n sa_ = a[i]-a[i-1]\n sa.append(sa_)\n#print(sa)\nk_last = k\nfor j in range(len(sa)):\n k_last -= sa[j]\n#print('k_last=',k)\n\nans = k_last - max(sa)\nif ans < 0:\n print(max(sa))\nelif ans == 0:\n print(k)\nelse:\n print(ans)", 'k,n = map(int,input().split())\na = list(map(int,input().split()))\n\nsa = []\nfor i in range(1,n):\n sa_ = a[i]-a[i-1]\n sa.append(sa_)\n\nsa.append(k-max(a)+min(a))\nans = sum(sa)-max(sa)\n# print(sa)\n# print(k)\n# print(sum(sa))\nprint(ans)']
['Wrong Answer', 'Accepted']
['s470126573', 's121219139']
[26644.0, 26444.0]
[159.0, 142.0]
[340, 239]