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
|
---|---|---|---|---|---|---|---|---|---|---|
p03274 | u576432509 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nx=list(map(int,input().split()))\n\nif x[n-1]<=0 :\n t=x[-k+1]\n print(t)\n\nelif x[0]>=0:\n t=x[k-1]\n print(t)\n\nelse:\n for i in range(n):\n if x[i]<0 and x[i+1]>=0 :\n i0=i+1\n break\n print(i0)\n tmin=10**9\n for i in range(i0,k):\n kt=i\n t=x[kt]*2-x[kt-k+1]\n print("1",kt,kt-k+1,t,x[kt],x[kt-k+1])\n if t<tmin:\n tmin=t\n for i in range(i0-1,i0+1-k-1,-1):\n kt=i\n t=-x[kt]*2+x[kt+k-1]\n print("2",kt,kt+k-1,t,x[kt],x[kt+k-1])\n if t<tmin:\n tmin=t\n print(tmin)', 'from bisect import bisect_left\n\nn,k=map(int,input().split())\nx=list(map(int,input().split()))\n\niz=bisect_left(x,0)\n f x[iz+1]==0:\n k=k-1\nif x[n-1]<=0 :\n t=-x[-k]\n print(t)\nelif x[0]>=0:\n t=x[k-1]\n print(t)\n\nelse:\n tmin=10**9\n for i in range(max(0,iz-(k-1)+1),min(iz,n-1-(k-1)+1)):\n kt=i\n t1=-x[kt]+x[kt+(k-1)]*2\n t2=-x[kt]*2+x[kt+(k-1)]\n if t1<tmin:\n tmin=t1\n if t2<tmin:\n tmin=t2\n print(tmin)\n \n', 'from bisect import bisect_right\nfrom bisect import bisect_left\n\nn,k=map(int,input().split())\n#n=100000\n#k=100000\n\nx=list(map(int,input().split()))\n\nif x[n-1]<0 :\n t=x[-k]\n print(1)\n print(t)\nelif x[n-1]==0 :\n t=x[-k+1]\n print(2)\n print(t)\n\nelif x[0]>0:\n t=x[k-1]\n print(3)\n print(t)\nelif x[0]==0:\n t=x[k-1-1]\n print(4)\n print(t)\n\nelse:\n iz=bisect_left(x,0)\n if x[iz+1]==0:\n for i in range(iz+2,min(iz+k,k)):\n kt=i\n t=x[kt]*2-x[kt-k+1]\n# print("1",kt,kt-k+1,t,x[kt],x[kt-k+1])\n if t<tmin:\n tmin=t\n for i in range(max(iz+2-k,0),iz):\n kt=i\n t=-x[kt]*2+x[kt+k-1]\n# print("2",kt,kt+k-1,t,x[kt],x[kt+k-1])\n if t<tmin:\n tmin=t\n else:\n tmin=10**9\n# print((iz-(k-1)+1),iz,n-1-(k-1))\n for i in range(max(0,iz-(k-1)+1),min(iz,n-1-(k-1))+1):\n kt=i\n t1=-x[kt]+x[kt+(k-1)]*2\n t2=-x[kt]*2+x[kt+(k-1)]\n# print("2",kt,kt+k-1,t,x[kt],x[kt+k-1])\n\n if t1<tmin:\n tmin=t1\n if t2<tmin:\n tmin=t2\n print(tmin)\n \n# 299993628 \n# 1000000000 \n ', 'from bisect import bisect_right\nfrom bisect import bisect_left\n\nn,k=map(int,input().split())\n#n=100000\n#k=100000\n\nx=list(map(int,input().split()))\n\nif x[n-1]<0 :\n t=x[-k]\n# print(1)\n print(t)\nelif x[n-1]==0 :\n t=x[-k+1]\n# print(2)\n print(t)\n\nelif x[0]>0:\n t=x[k-1]\n# print(3)\n print(t)\nelif x[0]==0:\n t=x[k-1-1]\n# print(4)\n print(t)\n\nelse:\n iz=bisect_left(x,0)-1\n if x[iz+1]==0:\n tmin=10**9\n# print((iz-(k-1)+1),iz,n-1-(k-1))\n for i in range(max(0,iz-(k-1)+1),min(iz,n-1-(k-1)+1)):\n kt=i\n t1=-x[kt]+x[kt+(k-1)-1]*2\n t2=-x[kt]*2+x[kt+(k-1)-1]\n# print("2",kt,kt+k-1,t,x[kt],x[kt+k-1])\n\n if t1<tmin:\n tmin=t1\n if t2<tmin:\n tmin=t2\n else:\n tmin=10**9\n# print((iz-(k-1)+1),iz,n-1-(k-1))\n for i in range(max(0,iz-(k-1)+1),min(iz,n-1-(k-1)+1)):\n kt=i\n t1=-x[kt]+x[kt+(k-1)]*2\n t2=-x[kt]*2+x[kt+(k-1)]\n# print("2",kt,kt+k-1,t,x[kt],x[kt+k-1])\n\n if t1<tmin:\n tmin=t1\n if t2<tmin:\n tmin=t2\n print(tmin)\n \n# 299993628 \n# 1000000000 \n \n', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\n\nxmin=(x[n-1]-x[0])*2\n\nfor i in range(n-k+1):\n x1=abs(x[i])+abs(x[i+k-1]-x[i])\n x2=abs(x[i+k-1])+abs(x[i+k-1]-x[i])\n xmin=min(xmin,x1,x2)\n\nprint(xmin)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s286908716', 's328061484', 's425722793', 's451175631', 's690026296'] | [14480.0, 2940.0, 14100.0, 14252.0, 14568.0] | [365.0, 18.0, 74.0, 79.0, 96.0] | [608, 480, 1244, 1272, 222] |
p03274 | u584083761 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['a,b = list(map(int, input().split()))\nn = list(map(int, input().split()))\n\nc = 0\nris = 0\nlenn = len(n)\nfor i, name in enumerate(n[::-1]):\n if name < 0:\n c += 1\n if c == b-1:\n ri = i\n rs = name\n ris = lenn - ri - 1\n break\n\nans = []\nans_sum = []\nfor i in range(b+1):\n if ris+b+i > lenn:\n break\n iii = n[(ris+i):(ris+b+i)]\n ans.append(iii)\n lln = iii[0]\n rrn = iii[1]\n ll = abs(lln)\n rr = abs(rrn)\n if ll >=0 and rr > 0:\n ans_sum.append(rr)\n elif ll <0 and rr <=0:\n ans_sum.append(ll)\n elif ll <= rr:\n ans_sum.append(2*ll + rr )\n else:\n ans_sum.append(ll + 2*rr)\n\nprint(min(ans_sum))', 'a,b = list(map(int, input().split()))\nn = list(map(int, input().split()))\n\nans = []\nfor i, name in enumerate(n):\n if b+i >a:\n break\n ans.append(min( (abs(n[i]) + abs(n[i +b-1] - n[i]), abs(n[i+b-1]) + abs(n[i +b-1] - n[i]) )) )\n\nprint(min(ans))'] | ['Runtime Error', 'Accepted'] | ['s406817448', 's847330021'] | [1435696.0, 14252.0] | [2201.0, 105.0] | [689, 258] |
p03274 | u591503175 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['#\nfrom resolve import resolve\n####################################\n####################################\n\n# \nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_入力例_1(self):\n input = """5 3\n-30 -10 10 20 50"""\n output = """40"""\n self.assertIO(input, output)\n\n def test_入力例_2(self):\n input = """3 2\n10 20 30"""\n output = """20"""\n self.assertIO(input, output)\n\n def test_入力例_3(self):\n input = """1 1\n0"""\n output = """0"""\n self.assertIO(input, output)\n\n def test_入力例_4(self):\n input = """8 5\n-9 -7 -4 -3 1 2 3 4"""\n output = """10"""\n self.assertIO(input, output)\n\n\nif __name__ == "__main__":\n unittest.main()\n', 'def resolve():\n \'\'\'\n code here\n \'\'\'\n N, K = [int(item) for item in input().split()]\n xs = [int(item) for item in input().split()]\n \n min_lr = 10**9\n min_rl = 10**9\n\n if N != K:\n for i in range(N-K+1):\n min_lr = min(min_lr, abs(xs[i]) + abs(xs[i+K-1] - xs[i]))\n min_rl = min(min_rl, abs(xs[i+K-1]) + abs(xs[i+K-1] - xs[i]))\n\n print(min(min_lr, min_rl))\n elif N ==1:\n print(abs(xs[0]))\n else:\n print(min(abs(xs[0]) + abs(xs[N-1] - xs[0]), abs(xs[N-1]) + abs(xs[N-1] - xs[0])))\n\nif __name__ == "__main__":\n resolve()\n'] | ['Runtime Error', 'Accepted'] | ['s374725846', 's278771560'] | [9228.0, 20516.0] | [28.0, 93.0] | [1149, 600] |
p03274 | u593590006 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nl=[int(i) for i in input().split()]\nl=[abs(i) for i in l]\nsm=sum(l[:k])\nmini=min(mini,sm)\nfor i in range(k,n):\n sm=sm-l[i-k]\n sm+=l[i]\n mini=min(mini,sm)\nprint(mini)', 'n,k=map(int,input().split())\nl=[int(i) for i in input().split()]\nright=[i for i in l if i>0]\nleft=[i for i in l if i<=0]\nif not left: \n sm=0 \n sm+=l[0]\n for i in range(1,k):\n sm+=l[i]-l[i-1]\n print(sm)\n exit()\nif not right: \n sm=0 \n l=[abs(i) for i in l]\n sm=l[0]\n for i in range(1,k):\n sm+=(l[i]-l[i-1])\n print(sm)\n exit()\n\nle=len(left)\nri=len(right)\nrl=[0]*le \nrr=[0]*ri \nleft=[abs(i) for i in left]\n#print(left)\nleft=left[::-1]\nrl[0]=left[0]\nfor i in range(1,le):\n rl[i]=rl[i-1]+(left[i]-left[i-1])\nrr[0]=right[0]\nmini=10**9 \nif len(left)>=k:\n mini=min(mini,rl[k-1])\nif len(right)>=k:\n mini=min(mini,rr[k-1])\nfor i in range(1,ri) :\n rr[i]=rr[i-1]+(right[i]-right[i-1])\n#print(rl)\n#print(rr)\nif k==n:\n print(sum(rl)+sum(rr))\n exit()\nfor a in range(1,len(left)):\n b=k-a \n #print(a,b,rl[a],rr[b-1])\n mini=min(mini,2*rl[a-1]+rr[b-1],rl[a-1]+2*rr[b-1])\nprint(mini)', "n,k=map(int,input().split())\nl=[int(i) for i in input().split()]\nright=[i for i in l if i>0]\nleft=[i for i in l if i<=0]\nif not left: \n sm=0 \n sm+=l[0]\n for i in range(1,k):\n sm+=(l[i]-l[i-1])\n print(sm)\n exit()\nif not right: \n sm=0 \n l=[abs(i) for i in l]\n l.sort()\n sm=l[0]\n for i in range(1,k):\n sm+=(l[i]-l[i-1])\n print(sm)\n exit()\nle=len(left)\nri=len(right)\nrl=[0]*le \nrr=[0]*ri \nleft=[abs(i) for i in left]\nleft=left[::-1]\nrl[0]=left[0]\nfor i in range(1,le):\n rl[i]=rl[i-1]+(left[i]-left[i-1])\nrr[0]=right[0]\nmini=10**20 \nfor i in range(1,ri) :\n rr[i]=rr[i-1]+(right[i]-right[i-1])\nif len(left)>=k:\n mini=min(mini,rl[k-1])\nif len(right)>=k:\n mini=min(mini,rr[k-1])\n#print(left,right,rl,rr)\nfor a in range(1,len(left)+1):\n b=k-a \n #print(a,b)\n if b>len(rr):\n #print('hsef')\n continue \n mini=min(mini,2*rl[a-1]+rr[b-1],rl[a-1]+2*rr[b-1])\nprint(mini)"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s338669665', 's928509836', 's405935930'] | [14224.0, 14364.0, 14360.0] | [54.0, 129.0, 134.0] | [203, 936, 941] |
p03274 | u597374218 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nx=sorted(list(map(int,input().split())))\na=[]\nfor i in range(n-k+1):\n l=x[i]\n r=x[i+k-1]\n a.append(min(abs(l)+abs(r-l),abs(r)+abs(l-r)))\nprint(a)', 'N,K=map(int,input().split())\nx=list(map(int,input().split()))\nn=N-K+1\nleft=[0]*n\nfor i in range(n):left[i]=abs(x[i])+abs(x[i]-x[i+K-1])\nx=x[::-1]\nright=[0]*n\nfor i in range(n):right[i]=abs(x[i])+abs(x[i]-x[i+K-1])\nprint(min(min(left),min(right)))'] | ['Wrong Answer', 'Accepted'] | ['s545288477', 's964761234'] | [14252.0, 14384.0] | [100.0, 92.0] | [183, 246] |
p03274 | u599170882 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nX = list(map(int, input().split()))\n\ndistance = max([X[-1] - X[0], -X[i], X[-1]])\nfor i in range(N-K+1):\n if X[i+K-1] < 0:\n distance = min(distance, -X[i])\n elif X[i] > 0:\n distance = min(distance, X[i+K-1])\n else:\n tmp_distance = X[i+K-1]-X[i]\n tmp_distance += min(X[i+K-1], -X[i])\n distance = min(distance, tmp_distance)\nprint(distance)\n', "N, K = map(int, input().split())\nX = list(map(int, input().split()))\n\ndistance = float('inf')\nfor i in range(N-K+1):\n tmp_distance = abs(X[i]) + abs(X[i+K-1]-X[i])\n distance = min(distance, tmp_distance)\n tmp_distance = abs(X[i+K-1]) + abs(X[i+K-1]-X[i])\n distance = min(distance, tmp_distance)\nprint(distance)\n"] | ['Runtime Error', 'Accepted'] | ['s417629968', 's698406158'] | [14224.0, 14224.0] | [42.0, 117.0] | [416, 323] |
p03274 | u606090886 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k = map(int,input().split())\nx = list(map(int,input().split()))\nflag = True\nfor i in range(n+1):\n if i == n or x[i] > 0:\n x.insert(i,0)\n zahyou = i\n break\nans = 10**18\nfor i in range(k+1):\n flag = True\n if zahyou + i < n+1 and zahyou -k+i >= 0:\n mainasu = x[zahyou]-x[zahyou-k+i]\n purasu = x[zahyou+i]-x[zahyou]\n if mainasu != 0 and purasu != 0:\n purasu += min(mainasu,purasu)\n print(purasu,mainasu)\n ans = min(ans,mainasu+purasu)\nprint(ans)', 'n,k = map(int,input().split())\nx = list(map(int,input().split()))\nflag = True\nfor i in range(n+1):\n if i == n or x[i] > 0:\n x.insert(i,0)\n zahyou = i\n break\nans = 10**18\nprint(x)\nfor i in range(k+1):\n mainasu = 0\n purasu = 0\n flag = True\n for j in range(k):\n a = zahyou-k+i+j\n if a >= 0 and a < n:\n if x[a] < 0:\n mainasu += x[a+1]-x[a]\n else:\n purasu += x[a+1]-x[a]\n else:\n flag = False\n print(a,purasu,mainasu,flag)\n if mainasu != 0 and purasu != 0:\n purasu += min(mainasu,purasu)\n if flag:\n ans = min(ans,mainasu+purasu)\nprint(ans)', 'n,k = map(int,input().split())\nx = list(map(int,input().split()))\nflag = True\nfor i in range(n+1):\n if i == n or x[i] > 0:\n x.insert(i,0)\n zahyou = i\n break\nans = 10**18\nfor i in range(k+1):\n flag = True\n if zahyou + i < n+1 and zahyou -k+i >= 0:\n mainasu = x[zahyou]-x[zahyou-k+i]\n purasu = x[zahyou+i]-x[zahyou]\n if mainasu != 0 and purasu != 0:\n purasu += min(mainasu,purasu)\n ans = min(ans,mainasu+purasu)\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s224985302', 's249791922', 's429590068'] | [14780.0, 29412.0, 14252.0] | [175.0, 2104.0, 126.0] | [523, 681, 490] |
p03274 | u608569568 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K = map(int,input().split(" "))\narray = list(map(int,input().split(" ")))\n\nminus = 0\nwhile array[minus] < 0 and minus < N:\n minus += 1\n\nfirst,last = max(minus-K,0),min(minus,N-K)\n\nans = 2(array[N-1]- array[0])\n\nfor i in range(first,last+1):\n m_dist, p_dist = array[i], array[K-1+i]\n if m_dist*p_dist <=0:\n dist_i = min(abs(m_dist),abs(p_dist))*2+max(abs(m_dist),p_dist)\n else:\n dist_i = max(abs(m_dist),abs(p_dist))\n ans = min(ans,dist_i)\n\nprint(ans)', 'N,K = map(int,input().split(" "))\narray = list(map(int,input().split(" ")))\n\nminus = 0\nwhile minus < N and array[minus]<0:\n minus += 1\n\nfirst,last = max(minus-K,0),min(minus,N-K)\n\nans = 2*(array[N-1]- array[0])\n\nfor i in range(first,last+1):\n m_dist, p_dist = array[i], array[K-1+i]\n if m_dist*p_dist <=0:\n dist_i = min(abs(m_dist),abs(p_dist))*2+max(abs(m_dist),p_dist)\n else:\n dist_i = max(abs(m_dist),abs(p_dist))\n ans = min(ans,dist_i)\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s482969931', 's191357114'] | [14484.0, 14128.0] | [60.0, 111.0] | [481, 480] |
p03274 | u609061751 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import sys\nimport numpy as np\nN, K = [int(x) for x in input().split()]\nx = np.array([int(x) for x in input().split()])\nif 0 in x:\n K -= 1\nif K == 0:\n print(0)\n sys.exit()\nxn = x[(x<0)]\nxn = xn[::-1]\nxp = x[(x>0)]\nans = []\nif len(xn) >= K:\n ans.append(abs(xn[K-1]))\nif len(xp) >= K:\n ans.append(abs(xp[K-1]))\n\nx = x.tolist()\nx = sorted(x,key=lambda x:abs(x))[:K+1]\nx = np.array(x)\nxn = x[(x<0)]\nxp = x[(x>0)]\nif len(xp) > 0 and len(xn) > 0:\n ans.append(xp[-1] + abs(xn[-1]) + min(xp[-1],abs(xn[-1])))\nprint(min(ans))\n', 'import sys\nimport numpy as np\nN, K = [int(x) for x in input().split()]\nx = np.array([int(x) for x in input().split()])\nif 0 in x:\n K -= 1\nx = x[np.nonzero(x)]\nif K == 0:\n print(0)\n sys.exit()\nans = []\nfor i in range(len(x)-K+1):\n if (x[i] < 0) != (x[i+K-1] < 0):\n ans.append(abs(x[i])+abs(x[i+K-1])+min(abs(x[i]),abs(x[i+K-1])))\n else:\n ans.append(max(abs(x[i]),abs(x[i+K-1])))\nprint(min(ans))'] | ['Wrong Answer', 'Accepted'] | ['s286875637', 's170890121'] | [23076.0, 23072.0] | [212.0, 557.0] | [534, 422] |
p03274 | u612975321 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import numpy as np\n\nINF = 10**9\n\nn, k = map(int,input().split())\nx = list(map(int, input().split()))\n\nxp = [0] + [INF]*(k)\nxm = [0] + [INF]*(k)\ncp, cm = 1, 1\nfor i in range(n):\n if x[i] >= 0 and cp < k+1:\n xp[cp] = x[i]\n cp += 1\n elif x[i] < 0 and cm < k+1:\n xm[cm] = -x[i]\n cm += 1\nxm.sort(reverse=True)\nprint(xp, xm)\nans = INF * 3\nfor i in range(k+1):\n d = xp[i] + 2 * xm[i]\n ans = min(ans, d)\n d = 2 * xp[i] + xm[i]\n ans = min(ans, d)\nprint(ans)', 'import numpy as np\nN,K = map(int,input().split())\nX = np.array(input().split(), dtype=np.int64)\n\nINF = 10 ** 18\nneg = np.concatenate([-X[X <= 0][::-1], np.full(N+1,INF,dtype=np.int64)])[:K]\npos = np.concatenate([X[X > 0], np.full(N+1,INF,dtype=np.int64)])[:K]\n\nanswer = INF\n\nanswer = min(answer, neg[-1])\n\nanswer = min(answer, pos[-1])\nif K >= 2:\n \n answer = min(answer, (neg[:K-1] * 2 + pos[K-2::-1]).min())\n \n answer = min(answer, (pos[:K-1] * 2 + neg[K-2::-1]).min())\n\nprint(answer)\n'] | ['Wrong Answer', 'Accepted'] | ['s011412656', 's307534232'] | [39060.0, 39772.0] | [252.0, 144.0] | [494, 566] |
p03274 | u613920660 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['from collections import deque\n\nN,K=map(int,input().strip().split())\nx=list(map(int,input().strip().split()))\ninf=10*8\n\nl=inf\ndp=x[N-K:N-1]\ni=0\nwhile N-K-i>=0:\n if dp[0]>=0:\n tmp=dp[K-1]\n elif dp[K-1]<=0:\n tmp=-dp[0]\n else:\n if dp[K-1]>=dp[0]:\n tmp=dp[0]*2+dp[K-1]\n else:\n tmp=dp[K-1]*2+dp[0]\n l=min(l,tmp)\n i+=1\n if N-K-i<0:\n break\n else:\n dp.appendleft(x[N-K-i])\n dp.pop()\nprint(l)', 'from collections import deque\n \nN,K=map(int,input().strip().split())\nx=list(map(int,input().strip().split()))\ninf=10**9\n \nl=inf\ndp=deque(x[N-K:N])\ni=0\nwhile True:\n if dp[0]>=0:\n tmp=dp[K-1]\n elif dp[K-1]<=0:\n tmp=-dp[0]\n else:\n if abs(dp[K-1])>=abs(dp[0]):\n tmp=abs(dp[0])*2+abs(dp[K-1])\n else:\n tmp=abs(dp[K-1])*2+abs(dp[0])\n l=min(l,tmp)\n i+=1\n if N-K-i<0:\n break\n else:\n dp.appendleft(x[N-K-i])\n dp.pop()\nprint(l)'] | ['Runtime Error', 'Accepted'] | ['s190418233', 's992868227'] | [20480.0, 20536.0] | [51.0, 108.0] | [474, 514] |
p03274 | u619144316 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import bisect\n\nN, K = map(int,input().split())\nX = list(map(int,input().split()))\n\ns = bisect.bisect_left(X,0)\nif 0 in X:\n K -= 1\nelse:\n bisect.insort_left(X,0)\n N += 1\n\nMIN = 2 * 10**8\nfor i in range(K+1):\n if s - K + i >= 0 and s + i <N:\n f = X[s -K+i]\n l = X[s+i]\n print(f,l)\n if abs(f) < abs(l):\n ans = abs(f) * 2 + abs(l)\n else:\n ans = abs(l) * 2 + abs(f)\n print(ans)\n MIN =min(MIN,ans)\n\nprint(MIN)', 'def main():\n n,k = map(int,input().split())\n X = list(map(int,input().split()))\n\n ans = 10**9\n\n for i in range(n-k+1):\n t1 = abs(X[i]) + abs(X[i] - X[i+k-1])\n t2 = abs(X[i+k-1]) + abs(X[i] - X[i+k-1])\n t = min(t1,t2)\n\n ans = min(ans,t)\n\n print(ans)\n\n\n\nmain()'] | ['Wrong Answer', 'Accepted'] | ['s119794702', 's556253364'] | [14660.0, 20108.0] | [197.0, 87.0] | [486, 301] |
p03274 | u619379081 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = list(map(int, input().split()))\nx = [int(inout()) for i in range(n)]\nans = [min(abs(x[i]), abs(x[i+k-1]))+x[i+k-1]-x[i] for i in range(n-k+1)]\nprint(min(ans))', 'n, k = list(map(int, input().split()))\nx = [int(input()) for i in range(n)]\nans = [min(abs(x[i]), abs(x[i+k-1]))+x[i+k-1]-x[i] for i in range(n-k+1)]\nprint(min(ans))', 'n, k = list(map(int, input().split()))\nx = list(map(int, input().split()))\nans = [min(abs(x[i]), abs(x[i+k-1]))+x[i+k-1]-x[i] for i in range(n-k+1)]\nprint(min(ans))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s080872533', 's598939712', 's545868096'] | [3060.0, 5624.0, 14252.0] | [18.0, 23.0, 74.0] | [165, 165, 164] |
p03274 | u620846115 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k = map(int,input().split())\nl = list(map(int,input().split()))\nfor i in range(n-k+1):\n if l[i] <0 and l[i+k]<0:\n print(abs(l[i]))\n elif l[i] >0 and l[i+k]>0:\n print(abs(l[i+k]))\n elif l[i] <0 and l[i+k]>0:\n print(min(abs(l[i]),l[i+k])*2 + max(abs(l[i]),l[i+k]))', 'n,k = map(int,input().split())\nl = list(map(int,input().split()))\nls = []\nfor i in range(n-k+1):\n if l[i] <0 and l[i+k]<0:\n ls.append(abs(l[i]))\n elif l[i] >0 and l[i+k]>0:\n ls.append(abs(l[i]))\n elif l[i] <0 and l[i+k]>0:\n ls.append(min(abs(l[i]),l[i+k])*2 + max(abs(l[i]),l[i+k]))\nprint(min(ls))', 'n,k = map(int,input().split())\nl = list(map(int,input().split()))\nls = []\nfor i in range(n-k):\n if l[i] <0 and l[i+k-1]<=0:\n ls.append(abs(l[i]))\n elif l[i] >=0 and l[i+k-1]>0:\n ls.append(abs(l[i+k-1]))\n elif l[i] =<0 and l[i+k-1]>=0:\n ls.append(2*min(abs(l[i]),l[i+k-1]) + max(abs(l[i]),l[i+k-1]))\nprint(min(ls))', 'n,k = map(int,input().split())\nl = list(map(int,input().split()))\nls = []\nfor i in range(n-k):\n if l[i] <0 and l[i+k]<0:\n ls.append(abs(l[i]))\n elif l[i] >0 and l[i+k]>0:\n ls.append(abs(l[i+k]))\n elif l[i] <0 and l[i+k]>0:\n ls.append(2*min(abs(l[i]),l[i+k]) + max(abs(l[i]),l[i+k]))\nprint(min(ls))', 'n,k = map(int,input().split())\nl = list(map(int,input().split()))\nls = []\nfor i in range(n-k+1):\n a = l[i]\n b = l[i+k-1]\n ls.append(min(abs(a)+abs(a-b), abs(b)+abs(a-b)))\nprint(min(ls))', 'n,k = map(int,input().split())\nl = list(map(input().split()))\nls = []\nfor i in range(n-k):\n if l[i] <0 and l[i+k]<0:\n ls.append(abs(l[i]))\n elif l[i] >0 and l[i+k]>0:\n ls.append(abs(l[i+k]))\n elif l[i] <0 and l[i+k]>0:\n ls.append(2*min(abs(l[i]),l[i+k]) + max(abs(l[i]),l[i+k]))\nprint(min(ls))', 'n,k = map(int,input().split())\nl = list(map(int,input().split()))\nls = []\nfor i in range(n-k+1):\n a = l[i]\n b = l[i+k-1]\n ls.append(min(abs(a)+abs(a-b), abs(b)+abs(a-b)))\nprint(min(ls))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s070697758', 's218064844', 's417239355', 's669829906', 's887221093', 's952048536', 's096560438'] | [20292.0, 20184.0, 8916.0, 20316.0, 9048.0, 17004.0, 20132.0] | [113.0, 95.0, 26.0, 104.0, 27.0, 35.0, 91.0] | [276, 309, 325, 309, 190, 305, 188] |
p03274 | u623349537 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\na = list(map(int, input().split()))\n\nmin_time = 2 * 10 ** 8\nfor i in range(N):\n print(i)\n if i + K > N:\n break\n if a[i] > 0:\n min_time = min(min_time, abs(a[i + K - 1]))\n break\n \n if a[i + K - 1] < 0:\n if i + K <= N and a[i + K] > 0:\n min_time = min(min_time, abs(a[i]))\n continue\n \n min_time = min(min_time, 2 * abs(a[i]) + abs(a[i + K - 1]), abs(a[i]) + 2 * abs(a[i + K - 1]))\n\nprint(min_time)', 'N, K = map(int, input().split())\na = list(map(int, input().split()))\n\nmin_time = 10 ** 12\nfor i in range(N):\n if i + K > N:\n break\n if a[i] > 0:\n min_time = min(min_time, abs(a[i + K - 1]))\n break\n \n if a[i + K - 1] < 0:\n if (i + K < N and a[i + K] > 0) or i + K == N:\n min_time = min(min_time, abs(a[i]))\n continue\n \n min_time = min(min_time, 2 * abs(a[i]) + abs(a[i + K - 1]), abs(a[i]) + 2 * abs(a[i + K - 1]))\n\nprint(min_time)'] | ['Runtime Error', 'Accepted'] | ['s364632327', 's686573456'] | [14480.0, 14844.0] | [143.0, 103.0] | [499, 498] |
p03274 | u623687794 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nc=list(map(int,input().split()))\nans=10**100\nfor i in range(n-k+1):\n lit=c[i:i+k]\n if lit[0]*lit[-1]>0:\n d=abs(lit[0])+abs(lit[-1])+min(abs(lit[0]),abs(lit[-1]))\n else:\n d=max(abs(lit[0],abs(lit[-1])))\n if d<ans:\n ans=d\nprint(ans)\n', 'n,k=map(int,input().split())\nc=list(map(int,input().split()))\nans=10**100\nfor i in range(n-k+1):\n lit=c[i:i+k]\n if lit[0]*lit[-1]>0:\n d=abs(lit[0])+abs(lit[-1])+min(abs(lit[0]),abs(lit[-1]))\n else:\n d=max(abs(lit[0],abs(lit[-1])))\n if d<ans:\n d=ans\nprint(ans)', 'n,k=map(int,input().split())\nc=list(map(int,input().split()))\nans=10**100\nfor i in range(n-k+1):\n l,r=i,i+k-1\n d=min(abs(c[l]),abs(c[r]))+abs(c[l]-c[r])\n if d<ans:\n ans=d\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s289625322', 's373442616', 's588796100'] | [14252.0, 14568.0, 14224.0] | [2104.0, 2104.0, 87.0] | [273, 272, 187] |
p03274 | u624475441 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K,*x=map(int,open(0).read().split());print(min(min(abs(x[i]),abs(x[i+k-1]))+x[i+k-1]-x[i]for i in range(n-k+1)))', 'n,k,*x=map(int,open(0).read().split());print(min(min(abs(x[i]),abs(x[i+k-1]))+x[i+k-1]-x[i]for i in range(n-k+1)))'] | ['Runtime Error', 'Accepted'] | ['s531841562', 's741921209'] | [14052.0, 14052.0] | [41.0, 71.0] | [114, 114] |
p03274 | u626881915 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\na = list(map(int,input().split()))\nminus = [a[i] for i in range(n) if a[i] < 0][::-1]\n\nplus = [a[i] for i in range(n) if a[i] > 0]\n\nmin_ = 10**18\n\nif len(plus) == 0:\n print(minus[k-1])\nelif len(minus) == 0:\n print(plus[k-1])\nelif len(plus) < len(minus):\n for i in range(min(k, len(plus))):\n min_ = min(2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])\n print(min_)\nelse:\n for i in range(min(k, len(minus))):\n min_ = min(2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])\n print(min_) \n \n', 'n,k=map(int,input().split())\na = list(map(int,input().split()))\nminus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]\n\nplus = [a[i] for i in range(n) if a[i] >= 0]\n\nmin_ = 10**18\n\nif len(plus) == 0:\n print(minus[k-1])\nelif len(minus) == 0:\n print(plus[k-1])\nelif len(plus) < len(minus):\n for i in range(min(k-1, len(plus))):\n min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])\n i += 1\n min_ = min(min_, plus[i])\n print(min_)\nelse:\n for i in range(min(k-1, len(minus))):\n min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])\n i += 1\n min_ = min(min_, minus[i])\n print(min_) \n \n', 'n,k=map(int,input().split())\na = list(map(int,input().split()))\nminus = [a[i] for i in range(n) if a[i] < 0][::-1]\n\nplus = [a[i] for i in range(n) if a[i] > 0]\n\nmin_ = 10**18\n\nfor i in range(min(k, len(plus))):\n min_ = min(2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])\nprint(min_)\n ', 'n,k=map(int,input().split())\na = list(map(int,input().split()))\nminus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]\n\nplus = [0]+[a[i] for i in range(n) if a[i] >= 0]\n\nmin_ = 10**18\n\nif len(plus) == 1:\n print(minus[k])\nelif len(minus) == 1:\n print(plus[k])\nelse:\n for i in range(min(k+1, len(plus))):\n if k-i < len(minus):\n min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])\n print(min_)\n \n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s519935028', 's552189160', 's683204193', 's692278979'] | [14660.0, 14252.0, 14252.0, 14480.0] | [95.0, 99.0, 81.0, 105.0] | [525, 622, 286, 420] |
p03274 | u629350026 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\nans=[]\nfor i in range(0,n-k+1):\n l=x[i]\n r=x[i+k-1]\n ans.append(min(abs(l)+abs(l-r),abs(r)+abs(l-r)))\nprint(ans)\nprint(min(ans))\n', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\nans=[]\nfor i in range(0,n-k+1):\n l=x[i]\n r=x[i+k-1]\n ans.append(min(abs(l)+abs(l-r),abs(r)+abs(l-r)))\nprint(min(ans))\n'] | ['Wrong Answer', 'Accepted'] | ['s333516632', 's059039085'] | [14252.0, 14252.0] | [93.0, 90.0] | [203, 192] |
p03274 | u631914718 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import sys\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\nif __name__ == "__main__":\n n, k = LI()\n X = LI()\n l_count = sum((x <= 0 for x in X))\n r_count = n - l_count\n\n if l_count == 0:\n print(X[k-1])\n elif r_count == 0:\n print(X[-k+1])\n else:\n times = []\n for i in range(l_count):\n try:\n left = X[l_count - i - 1]\n right = X[l_count + k - i - 2]\n times.append(abs(2 * left) + abs(right))\n times.append(abs(left) + abs(2 * right))\n except:\n continue\n print(times)\n print(min(times))\n', 'n, k, *x = map(int, open(0).read().split())\n\nprint(min([min(abs(x[i]), abs(x[i+k-1])) + (x[i+k-1] - x[i]) for i in range(n-k+1)]))'] | ['Wrong Answer', 'Accepted'] | ['s175925371', 's740274845'] | [14168.0, 14052.0] | [109.0, 73.0] | [952, 130] |
p03274 | u636137609 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ["N,K = map(int, input().split())\na = list(map(int, input().split()))\n\nif 0 in a:\n N = N - 1\n if N == 0:\n print('0')\n exit()\n\naLow = list(filter(lambda x: x < 0, a))\naLow = list(map(lambda x: abs(x), aLow))\naLow = aLow.sort()\n\naHigh = list(filter(lambda x: x > 0, a))\n\nleast = 99999999999999999\n\nfor i in range(0,len(aLow)):\n j = N - i\n if i == 0:\n dist = aHigh[j-1]\n elif j == 0:\n dist = aLow[i-1]\n else:\n dist = min(2*aLow[i-1]+aHigh[j-1], aLow[i-1]+2*aHigh[j-1])\n\n if least > dist:\n least = dist\n\nprint(least)\n", "N,K = map(int, input().split())\na = list(map(int, input().split()))\n\nif 0 in a:\n K = K - 1\n if K == 0:\n print('0')\n exit()\n\naLow = list(filter(lambda x: x < 0, a))\naLow = list(map(lambda x: abs(x), aLow))\naLow.sort()\n\naHigh = list(filter(lambda x: x > 0, a))\n\nleast = 99999999999999999\n\n#print(aLow)\n#print(aHigh)\n\nfor i in range(0,K+1):\n j = K - i\n if i > len(aLow) or j > len(aHigh):\n continue\n\n if i == 0:\n dist = aHigh[j-1]\n elif j == 0:\n dist = aLow[i-1]\n else:\n dist = min(2*aLow[i-1]+aHigh[j-1], aLow[i-1]+2*aHigh[j-1])\n\n if least > dist:\n least = dist\n\nprint(least)\n"] | ['Runtime Error', 'Accepted'] | ['s117386330', 's570676255'] | [14480.0, 14480.0] | [76.0, 119.0] | [536, 603] |
p03274 | u652081898 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = map(int, input().split())\nlist_original = list(map(int, input().split()))\n\nlist_original.append(0)\nlist = sorted(list_original)\npoint = list.index(0)\n\nif k <= point and point <= n-k+1:\n if abs(list[point-k]) <= list[point+k]:\n print(abs(list[point-k]))\n else:\n print(list[point])\nelif point < k:\n print(list[point+k])\nelse:\n print(abs(list[point-k]))', 'n, k = map(int, input().split())\nlist = list(map(int, input().split()))\n\nmaxl = abs(max(list))\nminl = abs(min(list))\n\nif maxl <= minl:\n print(maxl*2+minl)\nelse:\n print(minl*2+maxl)', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\nans = []\n\nfor i in range(n-k+1):\n if x[i+k-1] < 0:\n ans.append(abs(x[i]))\n elif x[i] > 0:\n ans.append(abs(x[i+k-1]))\n else:\n ans.append(min(abs(x[i])*2+abs(x[i+k-1]), abs(x[i])+abs(x[i+k-1])*2))\n\nprint(min(ans))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s131634231', 's403120660', 's757081688'] | [14384.0, 14392.0, 14224.0] | [45.0, 47.0, 97.0] | [383, 186, 310] |
p03274 | u667469290 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ["# -*- coding: utf-8 -*-\nimport numpy as np\n\ndef solve():\n N, K = map(int, input().split())\n C = np.array(list(map(int,input().split())))\n D = list()\n for i in range(N-K+1):\n c = C[i:i+K]\n l, r = max(c), min(c)\n d = -2*r + l if l > r else -r + 2*l\n D.append(d)\n return str(min(D))\n\nif __name__ == '__main__':\n print(solve())", "# -*- coding: utf-8 -*-\nimport numpy as np\n\ndef solve():\n N, K = map(int, input().split())\n C = np.array(list(map(int,input().split())))\n D = list()\n for i in range(N-K+1):\n c = C[i:i+K]\n l, r = max(c), min(c)\n d = -2*r + l if l > r else -r + 2*l\n D.append(d)\n return str(min(D)\n\nif __name__ == '__main__':\n print(solve())", "# -*- coding: utf-8 -*-\nimport numpy as np\n\ndef solve():\n N, K = map(int, input().split())\n C = np.array(list(map(int,input().split())))\n z = (C<0).sum()\n D = set()\n for i in range(N-K+1):\n l = -min(C[i],0)\n r = max(C[i+K-1],0)\n d = 2*l+r if l < r else 2*r+l\n D.add(d)\n return str(min(D))\n\nif __name__ == '__main__':\n print(solve())\n\n\n"] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s090485247', 's992458401', 's492713051'] | [23056.0, 2940.0, 23092.0] | [2108.0, 17.0, 414.0] | [362, 361, 384] |
p03274 | u672494157 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import sys\nfrom collections import deque\n\nsys.setrecursionlimit(4100000)\n\n\ndef inputs(num_of_input):\n ins = [input() for i in range(num_of_input)]\n return ins\n\n\ndef solve(N, K, inputs):\n candles = string_to_int(inputs[0])\n min_distance = -1\n for i in range(0, N-K+1):\n left = candles[i]\n right = candles[i+K-1]\n distance = 0\n if left <= 0 and right <= 0:\n distance = abs(left) - abs(right) + abs(0 - right)\n elif left >= 0 and right >= 0:\n distance = right\n else:\n if abs(right) > abs(left):\n distance = abs(left) + abs(left) + abs(right)\n else:\n distance = abs(right) + abs(right) + abs(left)\n if min_distance == -1 or min_distance > distance:\n min_distance = distance\n print(left, right)\n\n return min_distance\n\n\ndef string_to_int(string):\n return list(map(int, string.split()))\n\n\nif __name__ == "__main__":\n [N, K] = string_to_int(input())\n ret = solve(N, K, inputs(1))\n print(ret)\n', 'import sys\nfrom collections import deque\n\nsys.setrecursionlimit(4100000)\n\n\ndef inputs(num_of_input):\n ins = [input() for i in range(num_of_input)]\n return ins\n\n\ndef solve(N, K, inputs):\n candles = string_to_int(inputs[0])\n min_distance = -1\n for i in range(0, N-K+1):\n left = candles[i]\n right = candles[i+K-1]\n distance = 0\n if left <= 0 and right <= 0:\n distance = abs(left) - abs(right) + abs(0 - right)\n elif left >= 0 and right >= 0:\n distance = right\n else:\n if abs(right) > abs(left):\n distance = abs(left) + abs(left) + abs(right)\n else:\n distance = abs(right) + abs(right) + abs(left)\n if min_distance == -1 or min_distance > distance:\n min_distance = distance\n\n return min_distance\n\n\ndef string_to_int(string):\n return list(map(int, string.split()))\n\n\nif __name__ == "__main__":\n [N, K] = string_to_int(input())\n ret = solve(N, K, inputs(1))\n print(ret)\n'] | ['Wrong Answer', 'Accepted'] | ['s448781640', 's170291313'] | [15396.0, 15396.0] | [129.0, 70.0] | [1055, 1028] |
p03274 | u677312543 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nm = min(b - a + min(abs(a), bas(b)) for a, b in zip(x, x[k-1]))\nprint(m)', 'n, k = map(int, input().split())\nx = list(map(lambda x: int(x), input().split()))\n\nans = 0\nfor i in range(n-k+1):\n r = x[i+k-1]\n l = x[i]\n length = abs(r - l) + min(abs(l), abs(r))\n if length < ans:\n ans = length\n\nprint(ans)', 'n, k = map(int, input().split())\nx = list(map(lambda x: int(x), input().split()))\n\nfor i in range(n-k+1):\n r = x[i+k-1]\n l = x[i]\n length = abs(r - l) + min(abs(l), abs(r))\n if length < ans:\n ans = length\n\nprint(ans)', "n, k = map(int, input().split())\nx = list(map(lambda x: int(x), input().split()))\n\nans = float('inf')\nfor i in range(n-k+1):\n r = x[i+k-1]\n l = x[i]\n ans = min(ans, abs(r - l) + min(abs(l), abs(r)))\n\nprint(ans)"] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s077136212', 's189451759', 's833839745', 's447918740'] | [14224.0, 14228.0, 14224.0, 14252.0] | [44.0, 92.0, 55.0, 96.0] | [142, 243, 235, 219] |
p03274 | u677705680 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nX = list(map(int, input().split()))\n\nminus = [0]\nplus = [0]\nfor x in X:\n if x < 0:\n minus.append(abs(x))\n elif x == 0:\n K -= 1\n else:\n plus.append(x)\n\n\nminus.sort()\n\nans = []\nfor i in range(max(0, K - (len(plus) - 1)), min(len(minus) + 1, K)):\n print(i, K-i)\n ans.append(min(minus[i] * 2 + plus[K - i], minus[i] + plus[K - i] * 2))\n\nif len(X) == 1:\n ans.append(X[0])\n\nprint(min(ans))', 'N, K = map(int, input().split())\nX = list(map(int, input().split()))\n\nminus = [0]\nplus = [0]\nfor x in X:\n if x < 0:\n minus.append(abs(x))\n elif x == 0:\n K -= 1\n else:\n plus.append(x)\n\n\nminus.sort()\n\na = len(minus) - 1\nb = len(plus) - 1\n\nans = []\nfor i in range(max(0, K - b), min(a, K) + 1):\n ans.append(min(minus[i] * 2 + plus[K - i], minus[i] + plus[K - i] * 2))\n\nif len(X) == 1:\n ans.append(X[0])\n\nprint(min(ans))'] | ['Runtime Error', 'Accepted'] | ['s904307783', 's037965172'] | [14564.0, 14480.0] | [160.0, 97.0] | [510, 507] |
p03274 | u687044304 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['# -*- coding:utf-8 -*-\n\n\ndef solve():\n N, K = list(map(int, input().split()))\n X = list(map(int, input().split()))\n if 0 in X:\n \n K -= 1\n else:\n X.append(0)\n X.sort()\n\n origin_i = X.index(0)\n left_i = max(origin_i-K, 0)\n\n INF = 10**12\n ans = INF\n while left_i <= origin_i:\n if left_i+K < N:\n tmp = abs(X[left_i] - X[left_i+K])\n else:\n break\n ans = min(ans, tmp)\n left_i += 1\n print(ans)\n\nif __name__ == "__main__":\n solve()\n\n', '# -*- coding:utf-8 -*-\n\n\ndef solve():\n N, K = list(map(int, input().split()))\n X = list(map(int, input().split()))\n if 0 in X:\n \n K -= 1\n else:\n X.append(0)\n X.sort()\n\n origin_i = X.index(0)\n left_i = max(origin_i-K, 0)\n\n INF = 10**12\n ans = INF\n while left_i <= origin_i:\n if left_i+K < len(X):\n tmp1 = abs(X[left_i]-0)*2 + abs(X[left_i+K]-0)\n tmp2 = abs(X[left_i]-0) + abs(X[left_i+K]-0)*2\n else:\n break\n ans = min(ans, tmp1, tmp2)\n left_i += 1\n print(ans)\n\nif __name__ == "__main__":\n solve()\n\n'] | ['Wrong Answer', 'Accepted'] | ['s830585603', 's366244298'] | [14252.0, 14252.0] | [63.0, 87.0] | [1122, 1205] |
p03274 | u698501671 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K = map(int,input().split())\nx = list(map(int,input().split()))\n\nans = sum([abs(i) for i in x])\nfor i in range(N - K + 1):\n t = min(abs(x[i])+abs(x[i+K-1] - x[i]),abs(x[i+K-1]+abs(x[i+K-1]-x[i]))\n if t < ans:\n ans = t:\n\nprint(ans)', 'N, K = map(int, input().split())\nx = list(map(int, input().split()))\n\nmin_t = 10e9\nfor i in range(N - K + 1):\n e = i + K - 1\n l = min(x[i], 0)\n r = max(x[e], 0)\n\n t = min(-l, r) * 2 + max(-l, r)\n min_t = min(min_t, t)\n\nprint(min_t)\n'] | ['Runtime Error', 'Accepted'] | ['s623896327', 's838172314'] | [2940.0, 14224.0] | [17.0, 115.0] | [245, 247] |
p03274 | u699765883 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['from collections import deque\n\nN, K = map(int, input().split())\nx = list(map(int, input().split()))\n\nx_upper = []\n\nfor i in reversed(x):\n if i<0:\n break\n if i>=0:\n x_upper.append(i)\n x.pop()\n \n\nx.reverse()\nx_upper.reverse()\n\nlenXu = len(x_upper)\nlenX = len(x)\n\nif K>lenXu:\n min = K-lenXu-1\n max = lenXu-1\nelse:\n min = -1\n max = K-1\n\nS = []\nwhile min<K and min<lenX:\n if min>=0:\n if (x[min]*(-1))<x_upper[max]:\n S.append((x[min]*(-1))*2 + x_upper[max])\n else:\n S.append((x[min]*(-1)) + x_upper[max]*2)\n else:\n S.append(x_upper[max])\n min += 1\n max -= 1\n\nprint(S_stock)\n', 'from collections import deque\n\nN, K = map(int, input().split())\nx = list(map(int, input().split()))\n\nx_upper = []\n\nfor i in reversed(x):\n if i<0:\n break\n if i>=0:\n x_upper.append(i)\n x.pop()\n \n\nx.reverse()\nx_upper.reverse()\n\nlenXu = len(x_upper)\nlenX = len(x)\n\nif K>lenXu:\n l = K-lenXu-1\n h = lenXu-1\nelse:\n l = -1\n h = K-1\n\nS = []\nwhile l<K and l<lenX:\n if h<0:\n S.append(x[l]*(-1))\n elif l<0:\n S.append(x_upper[h])\n else:\n if (x[l]*(-1))<x_upper[h]:\n S.append((x[l]*(-1))*2 + x_upper[h])\n else:\n S.append((x[l]*(-1)) + x_upper[h]*2)\n l += 1\n h -= 1\n\nprint(min(S))\n'] | ['Runtime Error', 'Accepted'] | ['s899585157', 's619717842'] | [14628.0, 14628.0] | [95.0, 98.0] | [697, 705] |
p03274 | u701426727 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import copy\nnum = input().split(" ")\nzahyou = input().split(" ")\n\nnum[1] = int(num[1])\nplus = []\nminus = []\nrousoku = []\nfor i in range(int(num[0])):\n if(int(zahyou[i]) < 0):\n minus.append(int(zahyou[i]))\n else:\n plus.append(int(zahyou[i]))\n\n\n\nif(num[1] > len(plus)):\n plus_tmp = minus[(len(plus)-num[1]):] + plus\n minus_tmp = minus[:(len(minus)+len(plus_tmp)-num[1]-1)]\nrousoku = plus_tmp[0:num[1]]\nminus_tmp_2 = copy.deepcopy(minus_tmp)\nwhile(True):\n if(rousoku[-1] - rousoku[-2] >= (min(min(rousoku), 0) - minus_tmp_2[-1]) * 2):\n rousoku.pop(-1)\n rousoku.insert(0, minus_tmp_2.pop(-1))\n else:\n break\nrousoku_move_plus = []\nfor i in rousoku:\n rousoku_move_plus.append(i - min(rousoku) * 2)\n\n\nif(num[1] > len(minus)):\n minus_tmp = minus + plus[:(num[1]-len(minus))]\n plus_tmp = plus[(num[1]-len(minus)):]\nrousoku = minus_tmp[(-(num[1]+1)):]\nplus_tmp_2 = copy.deepcopy(plus_tmp)\nwhile(True):\n if(rousoku[1] - rousoku[0] >= (plus_tmp_2[0] - max(max(rousoku), 0)) * 2):\n rousoku.pop(0)\n rousoku.append(plus_tmp_2.pop(0))\n else:\n break\nrousoku_move_minus = []\nfor i in rousoku:\n rousoku_move_minus.append(max(rousoku) * 2 - i)\n\nprint(min(max(rousoku_move_plus), max(rousoku_move_minus)))\n', 'num = input().split(" ")\nzahyou = input().split(" ")\n\nnum[1] = int(num[1])\nplus = []\nminus = []\nrousoku = []\nfor i in range(int(num[0])):\n if(int(zahyou[i]) < 0):\n minus.append(int(zahyou[i]))\n else:\n plus.append(int(zahyou[i]))\n\n\n\nif(num[1] > len(plus)):\n plus_tmp = minus[(len(plus)-num[1]):] + plus\n minus_tmp = minus[:(len(minus)+len(plus_tmp)-num[1]-1)]\nrousoku = plus_tmp[0:num[1]]\nminus_tmp_2 = []\nfor i in minus_tmp:\n minus_tmp_2.append(i)\nwhile(True):\n if(rousoku[-1] - rousoku[-2] >= (min(min(rousoku), 0) - minus_tmp_2[-1]) * 2):\n rousoku.pop(-1)\n rousoku.insert(0, minus_tmp_2.pop(-1))\n else:\n break\nrousoku_move_plus = []\nfor i in rousoku:\n rousoku_move_plus.append(i - min(rousoku) * 2)\n\n\nif(num[1] > len(minus)):\n minus_tmp = minus + plus[:(num[1]-len(minus))]\n plus_tmp = plus[(num[1]-len(minus)):]\nrousoku = minus_tmp[(-(num[1]+1)):]\nplus_tmp_2 = []\nfor i in plus_tmp:\n plus_tmp_2.append(i)\nwhile(True):\n if(rousoku[1] - rousoku[0] >= (plus_tmp_2[0] - max(max(rousoku), 0)) * 2):\n rousoku.pop(0)\n rousoku.append(plus_tmp_2.pop(0))\n else:\n break\nrousoku_move_minus = []\nfor i in rousoku:\n rousoku_move_minus.append(max(rousoku) * 2 - i)\n\nprint(min(max(rousoku_move_plus), max(rousoku_move_minus)))\n', 'num = input().split(" ")\nzahyou = input().split(" ")\nzahyou_int = [int(i) for i in zahyou]\nnum[0] = int(num[0])\nnum[1] = int(num[1])\n\nrousoku = []\nflag = 1\ntime = 3 * 10 ** 8\nfor i in range(num[0]-num[1]+1):\n rousoku_min = zahyou_int[i]\n rousoku_max = zahyou_int[(i+num[1]-1)]\n if(flag == 0):\n break\n elif(rousoku_min > 0):\n flag = 0\n time_p = -min(0, rousoku_min) * 2 + rousoku_max\n time_m = max(0, rousoku_max) * 2 - rousoku_min\n if(min(time_p, time_m) < time):\n time = min(time_p, time_m)\n\n print(time)\n', 'num = input().split(" ")\nzahyou = input().split(" ")\nzahyou_int = [int(i) for i in zahyou]\nnum[0] = int(num[0])\nnum[1] = int(num[1])\n\nrousoku = []\nflag = 1\ntime = 3 * 10 ** 8\nfor i in range(num[0]-num[1]+1):\n rousoku_min = zahyou_int[i]\n rousoku_max = zahyou_int[(i+num[1]-1)]\n if(flag == 0):\n break\n elif(rousoku_min > 0):\n flag = 0\n time_p = -min(0, rousoku_min) * 2 + rousoku_max\n time_m = max(0, rousoku_max) * 2 - rousoku_min\n if(min(time_p, time_m) < time):\n time = min(time_p, time_m)\n\nprint(time)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s080071163', 's654878021', 's945066685', 's641766190'] | [17680.0, 17176.0, 14920.0, 14844.0] | [2105.0, 2104.0, 151.0, 114.0] | [1356, 1391, 551, 547] |
p03274 | u707124227 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nx=list(map(int,input().split()))\nx=list(range(1,n+1))\nxp=[xi for xi in x if xi>=0]\nxm=[xi for xi in x if xi<0]\nxm.sort(reverse=True)\nans=2*10**8\nfor i in range(k+1):\n if i>len(xp) or k-i>len(xm):\n continue\n a=xp[i-1] if len(xp)>0 else 0\n b=xm[k-i-1] if len(xm)>0 else 0\n ans=min(ans,2*a-b,a-2*b)\nprint(ans)\n\n', "def main():\n import bisect\n n,k=map(int,input().split())\n x=list(map(int,input().split()))\n ans=abs(x[0])*2+abs(x[-1])*2\n if 0 in x:\n r=x.index(0)\n l=max(0,r-(k-1))\n else:\n r=bisect.bisect_right(x,0)\n l=max(0,r-k)\n ans=2*abs(x[0])+2*abs(x[-1])\n for i in range(l,min(n-k+1,r+1)):\n if x[i]*x[i+k-1]<=0:\n a=min(abs(x[i]),abs(x[i+k-1]))\n b=max(abs(x[i]),abs(x[i+k-1]))\n ans=min(ans,2*a+b)\n else:\n b=max(abs(x[i]),abs(x[i+k-1]))\n ans=min(ans,b)\n print(ans)\nif __name__=='__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s376625293', 's151106128'] | [14564.0, 14380.0] | [76.0, 94.0] | [397, 538] |
p03274 | u707498674 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['from collections import Counter\nimport numpy as np\nH, W = map(int, input().split())\na = []\nr_idx = []\nc_idx = []\n#a.shape = (H, W)\nfor i in range(H):\n line = list(input())\n if Counter(line).most_common()[0][1] != W:\n r_idx.append(i)\n a.append(line)\na = np.array(a).T\n#a.shape = (W, H)\nb = []\nfor i in range(W):\n if Counter(a[i]).most_common()[0][1] == H:\n continue\n b.append(a[i])\n\nb = np.array(b).T\nc = []\nfor idx in r_idx:\n c.append(b[idx])\n\nfor i in range(len(c)):\n print("".join(c[i]))\n', 'N, K = map(int, input().split())\nx = list(map(int, input().split()))\ndist = 2 * (x[-1] - x[0])\nfor i in range(N):\n if i + K -1 >= N:\n break\n dist = min(dist, abs(x[i]) + abs(x[i + K - 1] - x[i]),abs(x[i + K -1]) + abs(x[i + K - 1] - x[i]))\nprint(dist)'] | ['Runtime Error', 'Accepted'] | ['s755638265', 's940598975'] | [21656.0, 14224.0] | [216.0, 103.0] | [525, 264] |
p03274 | u709304134 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['#coding:utf-8\n\n\n# ls = [-30,-10,10,20,50]\n\n# n,k = 3,2\n# ls=[10,20,30]\n\n# n,k = 1,1\n# ls = [0]\n\n#n,k=8,5\n#ls=[-9,-7,-4,-3,1,2,3,4]\n\nfirst = -1\nfor i,point in enumerate(ls):\n if point >= 0:\n first = i\n break\nsize=k+1\nans = []\nfor i in range(size):\n if first-size+i+1>=0 and first+i-1< len(ls):\n temp = [0,ls[first-size+i+1],ls[first+i-1]]\n temp = [abs(min(temp)),abs(max(temp))]\n ans.append((2*min(temp)+max(temp)))\nprint (min(ans))\n', '#coding:utf-8\n\nn,k = map(int,input().split())\nls = list(map(int,input().split()))\n\n\n# ls = [-30,-10,10,20,50]\n\n# n,k = 3,2\n# ls=[10,20,30]\n\n# n,k = 1,1\n# ls = [0]\n\n# n,k=8,5\n# ls=[-9,-7,-4,-3,1,2,3,4]\n\ndef set_max(ls):\n try:\n return set([max(ls)])\n except:\n return set()\ndef set_min(ls):\n try:\n return set([min(ls)])\n except:\n return set()\n\n\nplus = list(filter(lambda n:n>=0, ls))\nminus = list(filter(lambda n:n<=0, ls))\n\nneighbor = set_max(minus) | set_min(plus)\n\nprint (neighbor)\nanswer = []\nfor i in range(n-k+1):\n if len(set(ls[i:i+k])&neighbor)>0:\n print (ls[i:i+k])\n if sign(ls[i]*ls[i+k-1])<0:\n temp = [abs(ls[i]),abs(ls[i+k-1])]\n answer.append(2*min(temp)+max(temp))\n else:\n answer.append(2*max(temp))\nprint (min(answer))\n\n# first = -1\n# for i,point in enumerate(ls):\n# if point >= 0:\n# first = i\n# break\n# size=k+1\n# ans = []\n\n# if first-size+i+1>=0 and first+i-1< len(ls):\n# temp = [0,ls[first-size+i+1],ls[first+i-1]]\n# temp = [abs(min(temp)),abs(max(temp))]\n# ans.append((2*min(temp)+max(temp)))\n# print (min(ans))\n', '#coding:utf-8\nimport numpy as np\n# n,k = map(int,input().split())\n# ls = list(map(int,input().split()))\n\n\n# ls = [-30,-10,10,20,50]\n#\n# n,k = 3,2\n# ls=[10,20,30]\n\n# n,k = 1,1\n# ls = [0]\n\nn,k=8,5\nls=[-9,-7,-4,-3,1,2,3,4]\n\n\n\ndef set_max(ls):\n if len(ls)>0:\n return set([max(ls)])\n else:\n return set()\ndef set_min(ls):\n if len(ls)>0:\n return set([min(ls)])\n else:\n return set()\n\n\nplus = list(filter(lambda n:n>=0, ls))\nminus = list(filter(lambda n:n<=0, ls))\n\nneighbor = set_max(minus) | set_min(plus)\n\n#print (neighbor)\nanswer = []\ncnt = 0\nfor i in range(n-k+1):\n if len(set(ls[i:i+k])&neighbor)>0:\n\n #print (ls[i:i+k])\n #print (np.sign(ls[i]*ls[i+k-1]))\n temp = [abs(ls[i]),abs(ls[i+k-1])]\n if np.sign(ls[i]*ls[i+k-1])<0:\n\n answer.append(2*min(temp)+max(temp))\n else:\n answer.append(max(temp))\n cnt += 1\n if cnt == k + 1:\n break\nprint (min(answer))\n\n# first = -1\n# for i,point in enumerate(ls):\n# if point >= 0:\n# first = i\n# break\n# size=k+1\n# ans = []\n\n# if first-size+i+1>=0 and first+i-1< len(ls):\n# temp = [0,ls[first-size+i+1],ls[first+i-1]]\n# temp = [abs(min(temp)),abs(max(temp))]\n# ans.append((2*min(temp)+max(temp)))\n# print (min(ans))\n', 'first = -1\nfor i,point in enumerate(ls):\n if point >= 0:\n first = i\n break\nsize=k+1\nans = []\nfor i in range(size):\n if first-size+i+1>=0 and first+i-1< len(ls):\n temp = [0,ls[first-size+i+1],ls[first+i-1]]\n temp = [abs(min(temp)),abs(max(temp))]\n ans.append((2*min(temp)+max(temp)))\nprint (min(ans))', '#coding:utf-8\n\nn,k = map(int,input().split())\nls = list(map(int,input().split()))\n\n\n# ls = [-30,-10,10,20,50]\n\n# n,k = 3,2\n# ls=[10,20,30]\n\n# n,k = 1,1\n# ls = [0]\n\n# n,k=8,5\n# ls=[-9,-7,-4,-3,1,2,3,4]\n\ndef set_max(ls):\n try:\n return set([max(ls)])\n except:\n return set()\ndef set_min(ls):\n try:\n return set([min(ls)])\n except:\n return set()\n\n\nplus = list(filter(lambda n:n>=0, ls))\nminus = list(filter(lambda n:n<=0, ls))\n\nneighbor = set_max(minus) | set_min(plus)\n\nprint (neighbor)\nanswer = []\nfor i in range(n-k+1):\n if len(set(ls[i:i+k])&neighbor)>0:\n print (ls[i:i+k])\n temp = [0,ls[i],ls[i+k-1]]\n temp = [abs(min(temp)),abs(max(temp))]\n answer.append((2*min(temp)+max(temp)))\nprint (min(answer))\n\n# first = -1\n# for i,point in enumerate(ls):\n# if point >= 0:\n# first = i\n# break\n# size=k+1\n# ans = []\n\n# if first-size+i+1>=0 and first+i-1< len(ls):\n# temp = [0,ls[first-size+i+1],ls[first+i-1]]\n# temp = [abs(min(temp)),abs(max(temp))]\n# ans.append((2*min(temp)+max(temp)))\n# print (min(ans))\n', '#coding:utf-8\nimport numpy as np\nn,k = map(int,input().split())\nls = list(map(int,input().split()))\n\n\n# ls = [-30,-10,10,20,50]\n#\n# n,k = 3,2\n# ls=[10,20,30]\n\n# n,k = 1,1\n# ls = [0]\n\n# n,k=8,5\n# ls=[-9,-7,-4,-3,1,2,3,4]\n\ndef set_max(ls):\n if len(ls)>0:\n return set([max(ls)])\n else:\n return set()\ndef set_min(ls):\n if len(ls)>0\n return set([min(ls)])\n else:\n return set()\n\n\nplus = list(filter(lambda n:n>=0, ls))\nminus = list(filter(lambda n:n<=0, ls))\n\nneighbor = set_max(minus) | set_min(plus)\n\n#print (neighbor)\nanswer = []\nfor i in range(n-k+1):\n if len(set(ls[i:i+k])&neighbor)>0:\n #print (ls[i:i+k])\n #print (np.sign(ls[i]*ls[i+k-1]))\n temp = [abs(ls[i]),abs(ls[i+k-1])]\n if np.sign(ls[i]*ls[i+k-1])<0:\n\n answer.append(2*min(temp)+max(temp))\n else:\n answer.append(max(temp))\nprint (min(answer))\n\n# first = -1\n# for i,point in enumerate(ls):\n# if point >= 0:\n# first = i\n# break\n# size=k+1\n# ans = []\n\n# if first-size+i+1>=0 and first+i-1< len(ls):\n# temp = [0,ls[first-size+i+1],ls[first+i-1]]\n# temp = [abs(min(temp)),abs(max(temp))]\n# ans.append((2*min(temp)+max(temp)))\n# print (min(ans))\n', '#coding:utf-8\nimport numpy as np\nn,k = map(int,input().split())\nls = list(map(int,input().split()))\n\n\n# ls = [-30,-10,10,20,50]\n#\n# n,k = 3,2\n# ls=[10,20,30]\n\n# n,k = 1,1\n# ls = [0]\n\n# n,k=8,5\n# ls=[-9,-7,-4,-3,1,2,3,4]\nif not (0 in ls):\n ls.append(0)\n k+=1\n#print (ls)\n\nls = np.array(ls)\nls.sort()\n#print (ls)\n\nidx = np.where(ls==0)[0][0]\n#print (idx,k)\n#print (idx+k)\nstart = max(0,idx-k)\ngoal = min(idx+k,len(ls)-1)\n\n#print (start,goal)\nanswer = []\nfor i in range(goal-(k-1)+1):\n #print (i,i+k-1)\n mi = min(abs(ls[i]),abs(ls[i+k-1]))\n ma = max(abs(ls[i]),abs(ls[i+k-1]))\n #print (mi,ma)\n answer.append(2*mi+ma)\nprint (min(answer))\n\n# if len(ls)>0:\n# return set([max(ls)])\n# else:\n# return set()\n\n# if len(ls)>0:\n# return set([min(ls)])\n# else:\n# return set()\n#\n#\n\n# minus = list(filter(lambda n:n<=0, ls))\n#\n\n#\n# #print (neighbor)\n# answer = []\n# cnt = 0\n\n# if len(set(ls[i:i+k])&neighbor)>0:\n#\n# #print (ls[i:i+k])\n# #print (np.sign(ls[i]*ls[i+k-1]))\n# temp = [abs(ls[i]),abs(ls[i+k-1])]\n# if np.sign(ls[i]*ls[i+k-1])<0:\n#\n# answer.append(2*min(temp)+max(temp))\n# else:\n# answer.append(max(temp))\n# cnt += 1\n\n# break\n# print (min(answer))\n\n# first = -1\n# for i,point in enumerate(ls):\n# if point >= 0:\n# first = i\n# break\n# size=k+1\n# ans = []\n\n# if first-size+i+1>=0 and first+i-1< len(ls):\n# temp = [0,ls[first-size+i+1],ls[first+i-1]]\n# temp = [abs(min(temp)),abs(max(temp))]\n# ans.append((2*min(temp)+max(temp)))\n# print (min(ans))\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s011718684', 's044896338', 's112566404', 's212461889', 's579614204', 's753119549', 's451387469'] | [3060.0, 16160.0, 12432.0, 3064.0, 142788.0, 2940.0, 23048.0] | [17.0, 2104.0, 148.0, 17.0, 2104.0, 16.0, 540.0] | [486, 1208, 1354, 340, 1152, 1282, 1850] |
p03274 | u716043626 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = map(int,input().split())\nx = list(map(int,input().split()))\nx.append(0)\nx.sort()\nans = 10 ** 18\nfor i in range(n-k+1):\n cnt = 0\n cnt += abs(x[i])\n for j in range(i,k+i):\n cnt += abs(x[j+1] - x[j]) \n if cnt < ans:\n ans = cnt\n\nprint(min(ans))', 'n, k = map(int,input().split())\nx = list(map(int,input().split()))\nx.append(0)\nx.sort()\nans = 100000000\nfor i in range(n-k+1):\n cnt = 0\n cnt += abs(x[i])\n for j in range(i,k+i):\n cnt += abs(x[j+1] - x[j]) \n if cnt < ans:\n ans = cnt\n\nprint(min(ans))', 'n, k = map(int,input().split())\nx = list(map(int,input().split()))\nx.append(0)\nx.sort()\nans = 100\nfor i in range(n-k+1):\n cnt = 0\n cnt += abs(x[i])\n for j in range(i,k+i):\n cnt += abs(x[j+1] - x[j]) \n if cnt < ans:\n ans = cnt\n\nprint(min(ans))', 'n, k = map(int,input().split())\nx = list(map(int,input().split()))\nresult = []\nfor i in range(n-k+1):\n l, r = x[i], x[i+k-1]\n if l * r >= 0:\n result.append(max(abs(l), abs(r)))\n else:\n result.append(abs(2*l-r))\n result.append(abs(2*r-l))\nprint(min(result))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s529871862', 's654769669', 's797273029', 's901587432'] | [14252.0, 14380.0, 14252.0, 14392.0] | [2104.0, 2104.0, 2104.0, 83.0] | [276, 277, 271, 286] |
p03274 | u733608212 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['\nn, k = map(int, input().split())\nli = list(map(int, input().split()))\nli.append(0)\nli.sort()\nzero_index = li.index(0)\nif zero_index == 0:\n print(li[k])\nelif zero_index == len(li) -1:\n print(abs(li[-k-1]))\nelse:\n near_zero_small = li[zero_index-1]\n near_zero_big = li[zero_index+1]\n li.pop(zero_index)\n ans = 0\n cost = 0\n for i in range(n):\n minimam = li[i]\n maximam = li[i+k-1]\n if (minimam > 0 and maximam > 0 ):\n if minimam == near_zero_big:\n cost = maximam\n elif (minimam < 0 and maximam < 0 ):\n if minimam == near_zero_big:\n cost = abs(minimam)\n else:\n cost = min(abs(minimam), maximam)*2 + max(abs(minimam), maximam)\n if ans > cost or ans == 0:\n ans = cost\n print(ans)', '\nn, k = map(int, input().split())\nli = list(map(int, input().split()))\nli.append(0)\nli.sort()\nzero_index = li.index(0)\nif zero_index == 0:\n print(li[k])\nelif zero_index == len(li) -1:\n print(abs(li[-k-1]))\nelse:\n near_zero_small = li[zero_index-1]\n near_zero_big = li[zero_index+1]\n li.pop(zero_index)\n ans = 0\n cost = 0\n for i in range(n-k+1):\n minimam = li[i]\n maximam = li[i+k-1]\n if (minimam > 0 and maximam > 0 ):\n if minimam == near_zero_big:\n cost = maximam\n elif (minimam < 0 and maximam < 0 ):\n if minimam == near_zero_big:\n cost = abs(minimam)\n else:\n cost = min(abs(minimam), maximam)*2 + max(abs(minimam), maximam)\n if ans > cost or ans == 0:\n ans = cost\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s783182625', 's590998728'] | [14480.0, 14480.0] | [97.0, 94.0] | [817, 821] |
p03274 | u745561510 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nx = list(map(int,input().split()))\n\ncandidate = []\nfor i in range(N - K + 1):\n tmp = []\n for j in range(i, i + K):\n tmp.append(x[j])\n candidate.append(tmp)\n\n\n\n\ncheck = 0\nans = 10000000\nfor i in candidate:\n tmp = 0\n \n if i[0] < 0:\n \n if i[-1] > 0:\n \n if i[0] > i[-1]:\n tmp += abs(i[-1]) * 2\n tmp += abs[i[0]]\n \n else:\n tmp += abs(i[0]) * 2\n tmp += abs(i[-1])\n \n tmp += i[0]\n else:\n \n tmp += i[-1]\n ans = min(ans, tmp)\nprint(ans)\n', 'N, K = map(int, input().split())\nx = list(map(int,input().split()))\n\nans = 100000000000\n\nfor i in range(N - K + 1):\n tmp_min = x[i]\n tmp_max = x[i + K - 1]\n ans = min(ans, min(abs(tmp_min), abs(tmp_max)) + abs(tmp_min - tmp_max))\nprint(ans)\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s197284909', 's866351109'] | [141616.0, 14384.0] | [2113.0, 85.0] | [914, 289] |
p03274 | u754651673 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['#my answer\nn, k = map(int,input().split())\nx = list(map(int,input().split()))\n\nns = 999999999\n\nfor i in range(n - k + 1):\n a = abs(x[i]) + (x[i + k - 1] - x[i])\n b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])\n ans = min(ans, a, b)\n \nprint(ans)', '\nn, k = map(int,input().split())\nx = list(map(int, input().split()))\n\nns = 999999999\n\nfor i in range(n - k + 1):\n a = abs(x[i]) + (x[i + k - 1] - x[i])\n b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])\n ans = min(ans, a, b)\n \nprint(ans)', '#my answer\nn = int(input())\nk = int(input())\n\nL = []\nR = []\n\nfor i in range(n):\n x = int(input())\n if(x < 0):\n L.append(abs(x))\n elif(x >= 0):\n R.append(abs(x))\n\nx = L + R\n\nl = len(L) - k\nif(l < 0):\n l = 0\nr = l + k - 1\n\nans = 99999999;\nfor i in range(n - k):\n ans = min(ans, x[r]*2 + x[l])\n ans = min(ans, x[l]*2 + x[r])\n r += 1\n l += 1\n \nif(k == 1):\n ans = min(x[r], x[r-1])\n \nprint(ans)', 'n, k = map(int,input().split())\nx = list(map(int, input().split()))\n\nans = 999999999\n\nfor i in range(n - k + 1):\n\tif(x[i] <= 0 and x[i + k - 1] >= 0):\n \ta = abs(x[i]) + (x[i + k - 1] - x[i])\n \tb = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])\n \tans = min(ans, a, b)\n\nprint(ans)\n', 'n, k = map(int,input().split())\nx = list(map(int, input().split()))\n\nans = 999999999\n\nfor i in range(n - k + 1):\n a = abs(x[i]) + (x[i + k - 1] - x[i])\n b = abs(x[i + k - 1]) + (x[i + k - 1] - x[i])\n ans = min(ans, a, b)\n \nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s388025960', 's575755887', 's653520607', 's721775496', 's674929367'] | [14224.0, 14252.0, 3064.0, 2940.0, 14224.0] | [42.0, 42.0, 17.0, 17.0, 99.0] | [254, 245, 436, 283, 245] |
p03274 | u757030836 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K = map(int,input().split())\nx = [int(i) for i in input().split()]\nans = 10**5\nfor i in range(N-K+1):\n left =x[i]\n right =x[i+3]\n p1 = abs(left) + abs(right-left)\n p2 = abs(right) + abs(right-left)\n p = min(p1,p2)\n ans = min(ans,p)\n \n \nprint(ans)\n ', 'N,K = map(int,input().split())\nx = [int(i) for i in input().split()]\na=[]\nfor i in range(N-K+1):\n left =x[i]\n right =x[i+K-1]\n p1 = abs(left) + abs(right-left)\n p2 = abs(right) + abs(right-left)\n p = min(p1,p2)\n a.append(p)\n \n \nprint(min(a))\n '] | ['Runtime Error', 'Accepted'] | ['s011697955', 's730134688'] | [14224.0, 14384.0] | [96.0, 99.0] | [259, 252] |
p03274 | u759726213 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nX = list(map(int, input().split()))\n\nmax = 10000000000000000000000000\nfor i in range(N - K + 1):\n \n t_1 = abs(X[i])\n t_1 += X[i + K - 1] - X[i]\n\n t_2 = abs(X[i + K - 1])\n t_2 = X[i] - X[i + K - 1]\n\n if t_1 < max:\n max = t_1\n if t_2 < max:\n max = t_2\n\nprint(max)\n', 'N, K = map(int, input().split())\nX = list(map(int, input().split()))\n\n\nmax = 10000000000000000000000000\nfor i in range(N - K + 1):\n \n diff = X[i + K - 1] - X[i]\n t_1 = abs(X[i])\n t_1 += diff\n t_2 = abs(X[i + K - 1])\n t_2 += diff\n\n if t_1 < max:\n max = t_1\n if t_2 < max:\n max = t_2\n\nprint(max)\n'] | ['Wrong Answer', 'Accepted'] | ['s081224599', 's061080579'] | [14252.0, 14252.0] | [86.0, 84.0] | [337, 339] |
p03274 | u784022244 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=map(int, input().split())\n\nA=list(map(int, input().split()))\n\nans=10**8\nfor i in range(N-K+1):\n L=A[i]\n R=A[i+K-1]\n ans=min(ans, R-L+min(R, L))\n \nprint(ans)', 'import numpy as np\nN,K=map(int, input().split())\nX=list(map(int, input().split()))\nans=np.inf\nfor i in range(N-K+1):\n l=X[i]\n r=X[i+K-1]\n ans=min(ans, r-l+min(abs(l), abs(r)))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s207613548', 's823592424'] | [15020.0, 23096.0] | [79.0, 315.0] | [164, 189] |
p03274 | u785578220 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['def a():return input()#s\ndef ai():return int(input())#a,n or k\ndef ma():return map(int, input().split())#a,b,c,d or n,k\ndef ms():return map(str, input().split())#,a,b,c,d\ndef lma():return list(map(int, input().split()))#x or y\ndef lms():return list(map(str, input().split()))#x or y\na,b = ma()\nx = lma()\nans = 10 **18\nfor i in range(a-b+1):\n a0 = x[i]\n ab = x[i+b-1]\n if ab< 0 :\n ans = min(ans,ab)\n elif a0 <=0 and 0 <= ab:\n ans = min(ans, ab-2*a0, 2*ab-a0)\n else:\n ans = min(ans,a0)\nprint(ans)', 'def a():return input()#s\ndef ai():return int(input())#a,n or k\ndef ma():return map(int, input().split())#a,b,c,d or n,k\ndef ms():return map(str, input().split())#,a,b,c,d\ndef lma():return list(map(int, input().split()))#x or y\ndef lms():return list(map(str, input().split()))#x or y\na,b = ma()\nx = lma()\nans = 10 **18\nfor i in range(a-b+1):\n a0 = x[i]\n ab = x[i+b-1]\n if ab< 0 :\n ans = min(ans,abs(a0))\n elif a0 <=0 and 0 <= ab:\n ans = min(ans, ab-2*a0, 2*ab-a0)\n else:\n ans = min(ans,ab)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s430560324', 's134982210'] | [14484.0, 14660.0] | [80.0, 80.0] | [531, 537] |
p03274 | u787562674 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nx = [int(i) for i in input().split()]\n\ntime = 10 ** 20\n\nbase = 0\n\nfor i in range(N):\n if x[i] >= 0:\n base = x[i]\n break\n\nfor i in range(N - K + 1):\n if x[i+K-1] < 0:\n time = min(abs(x[i]) * 2, time)\n elif x[i] < 0 and x[i+K-1] >= 0:\n time = min(min(abs(x[i]), x[i+K-1]) * 2 + max(abs(x[i]), x[i+K-1]), time)\n print(time)\n else:\n time = min(x[i+K-1] * 2, time)\n\nprint(time)', 'N, K = map(int, input().split())\nx = [int(i) for i in input().split()]\n\ntime = 10 ** 20\n\nbase = 0\n\nfor i in range(N):\n if x[i] >= 0:\n base = x[i]\n break\n\nfor i in range(N - K + 1):\n if x[i+K-1] < 0:\n time = min(abs(x[i+K-1]) * 2, time)\n elif x[i] < 0 and x[i+K-1] >= 0:\n time = min(min(abs(x[i]), x[i+K-1]) * 2 + max(abs(x[i]), x[i+K-1]), time)\n else:\n time = min(x[i] * 2, time)\n\nprint(time)\n', 'N, K = map(int, input().split())\nx = [int(i) for i in input().split()]\n\ntime = 10 ** 20\n\nbase = 0\nindex = 0\n\nfor i in range(N):\n if x[i] >= 0:\n base = x[i]\n index = i\n break\nelse:\n index = -1\n\nif index == 0:\n time = x[K-1]\nelif index == -1:\n time = abs(x[N-K])\nelse:\n for i in range(max(0, index - K), min(index, N)):\n if x[i+K-1] < 0:\n time = min(abs(x[i]), time)\n elif x[i] < 0 and x[i+K-1] >= 0:\n time = min(min(abs(x[i]), x[i+K-1]) * 2 + max(abs(x[i]), x[i+K-1]), time)\n else:\n time = min(x[i+K-1], time)\n\nprint(time', 'N, K = map(int, input().split())\nx = [int(i) for i in input().split()]\n\ntime = 10 ** 20\n\nfor i in range(N - K + 1):\n x_min = x[i]\n x_max = x[i + K - 1]\n this_time = 0\n if x_min >= 0:\n this_time = x_max\n elif x_max <= 0:\n this_time = abs(x_min)\n else:\n this_time = x_max - x_min + min(x_max, abs(x_min))\n if time > this_time:\n time = this_time\n\nprint(this_time)', 'N, K = map(int, input().split())\nx = [int(i) for i in input().split()]\n\ntime = 10 ** 20\n\nbase = 0\nindex = 0\n\nfor i in range(N):\n if x[i] >= 0:\n base = x[i]\n index = i\n break\n\nfor i in range(base - K, base + 1):\n if x[i+K-1] < 0:\n time = min(abs(x[i]) * 2, time)\n elif x[i] < 0 and x[i+K-1] >= 0:\n time = min(min(abs(x[i]), x[i+K-1]) * 2 + max(abs(x[i]), x[i+K-1]), time)\n else:\n time = min(x[i+K-1] * 2, time)\n\nprint(time)', '\n\n\nN, K = map(int, input().split())\nx = [int(i) for i in input().split()]\n\ntime = 10 ** 20\n\nfor i in range(N - K + 1):\n x_min = x[i]\n x_max = x[i + K - 1]\n if x_min >= 0:\n this_time = x_max\n elif x_max <= 0:\n this_time = abs(x_min)\n else:\n this_time = x_max - x_min + min(x_max, abs(x_min))\n\n if time > this_time:\n time = this_time\n\nprint(time)'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s060945542', 's365683194', 's743997374', 's828264466', 's923529341', 's075225768'] | [14480.0, 14844.0, 3064.0, 14228.0, 14664.0, 14252.0] | [164.0, 120.0, 17.0, 81.0, 104.0, 85.0] | [487, 468, 642, 409, 504, 520] |
p03274 | u788137651 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['\n\nN, K = map(int, input().split())\nINF = 10**9\nx_first = [-INF for i in range(K)]\nx_ap = [int(i) for i in input().split()]\nif min(x_ap) < 0:\n print("S")\nx_last = [INF for i in range(K)]\nx = x_first + x_ap + x_last + [0]\nx.sort()\nzero_index = x.index(0)\n\nkey = []\nfor i in range(K):\n left = abs(x[zero_index - i])\n right = abs(x[zero_index - i + K])\n \n if left > right:\n right *= 2\n else:\n left *= 2\n key.append(left + right)\nprint(min(key))\n', 'N, K = map(int, input().split())\nx = [int(i) for i in input().split()]\nkey = []\nfor left, right in zip(x, x[K - 1:]):\n key.append(right-left+min(abs(left), abs(right)))\nprint(min(key))\n'] | ['Wrong Answer', 'Accepted'] | ['s868357458', 's668954386'] | [18280.0, 14252.0] | [143.0, 70.0] | [615, 188] |
p03274 | u793460864 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nx = list(map(int, input().split()))\nL = [0]*(N-K+1) \n\nfor i in range(N-K+1):\n L[i] = min((abs(x[i])+abs(x[i+K-1]-x[i])),(abs(x[i+K-1])+abs(x[i+K-1]-x[i]))\n \nprint(min(L))', 'N, K = map(int, input().split())\nx = list(map(int, input().split()))\nL = [0]*(N-K+1) \n \nfor i in range(N-K+1):\n if x[i] <= 0 and x[i+K-1] <= 0:\n L[i] = -x[i]\n elif x[i] <= 0 and x[i+K-1] >= 0:\n L[i] = min ((2*x[i+K-1]-x[i]),(-2*x[i]+x[i+K-1]))\n elif x[i] >= 0 and x[i+K-1] >= 0:\n L[i] = x[i+K-1]\nprint(min(L))'] | ['Runtime Error', 'Accepted'] | ['s571324055', 's865737470'] | [2940.0, 14564.0] | [17.0, 100.0] | [213, 341] |
p03274 | u795630164 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ["N, K = map(int, input().split())\nx = []\ny = []\nfor i in input().split():\n n = int(i)\n if n < 0:\n x.append(-n)\n elif n == 0:\n K -= 1\n else:\n y.append(n)\n\nx = x[::-1]\n\nlen_x = len(x)\nlen_y = len(y)\nnow = 10 ** 18\n\nif len_x == 0:\n if len_y == 0:\n print(0)\n else:\n print(y[K-1])\nelif len_y == 0:\n print(x[K-1])\nelse:\n for i in range(max(K - len_x, 0), K+1):\n if len_x < i:\n break\n print('x',i, K-i)\n if i == 0:\n now = min(x[K-1], now)\n elif i == K:\n now = min(y[K-1], now)\n else:\n now = min(min(x[i-1], y[K-i-1]) + x[i-1] + y[K-i-1], now)\n\n print(now)", 'N, K = map(int, input().split())\nx = []\ny = []\nfor i in input().split():\n n = int(i)\n if n < 0:\n x.append(-n)\n elif n == 0:\n K -= 1\n else:\n y.append(n)\n\nx = x[::-1]\n\nlen_x = len(x)\nlen_y = len(y)\nnow = 10 ** 18\n\nif len_x == 0:\n if len_y == 0:\n print(0)\n else:\n print(y[K-1])\nelif len_y == 0:\n print(x[K-1])\nelse:\n for i in range(K+1):\n if K - i > len_y:\n continue\n if len_x < i:\n break\n if i == 0:\n now = min(y[K-1], now)\n elif i == K:\n now = min(x[K-1], now)\n else:\n now = min(min(x[i-1], y[K-i-1]) + x[i-1] + y[K-i-1], now)\n\n print(now)'] | ['Runtime Error', 'Accepted'] | ['s232242808', 's088428882'] | [14252.0, 14480.0] | [184.0, 119.0] | [688, 690] |
p03274 | u798316285 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nX=list(map(int,input().split()))\nans=[]\nfor i in range(n-k+1):\n ans.append(X[i+k-1]-X[i]+min(abs(X[i+k+1]),abs(X[i])))\nprint(min(ans))', 'n,k=map(int,input().split())\nX=list(map(int,input().split()))\nans=[]\nfor i in range(n-k+1):\n ans.append(X[i+k-1]-X[i]+min(abs(X[i+k-1]),abs(X[i])))\nprint(min(ans))'] | ['Runtime Error', 'Accepted'] | ['s322732152', 's055108915'] | [14224.0, 14224.0] | [82.0, 84.0] | [164, 164] |
p03274 | u798818115 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['# coding: utf-8\n# Your code here!\nN,K=map(int,input().split())\nX=list(map(int,input().split()))\n\ndef journey(main,sub):\n if len(main)==1:\n main.append(10**18)\n elif len(sub)==1:\n sub.append(10**18)\n dp=0\n nm=1\n ns=1\n ans=0\n for _ in range(K):\n dism=(main[nm]-main[nm-1])\n diss=(sub[ns]-sub[ns-1])\n print(nm,ns)\n if nm==len(main)-1:\n ans+=2*diss\n ns+=1\n elif ns==len(sub)-1:\n ans+=dism\n nm+=1\n elif dism>2*diss:\n ans+=diss*2\n ns+=1\n else:\n ans+=dism\n nm+=1\n return ans\n\ni=0\nwhile X[i]<0:\n i+=1\n\n\nneg=[0]\npos=[0]\nneg=neg+list(map(lambda x:x*(-1),X[:i][::-1]))\npos=pos+X[i:]\n\nprint(pos)\nprint(neg)\n\nprint(min(journey(pos,neg),journey(neg,pos)))\n', '# coding: utf-8\n# Your code here!\nimport bisect\n\nN,K=map(int,input().split())\nX=list(map(int,input().split()))\n\nzero=bisect.bisect_left(X,0)\n\nans=10**18\nstart=max(0,zero-K)\nfor i in range(start,start+N-K+1):\n #print(i)\n m=min(0,X[i])\n M=max(0,X[i+K-1])\n ans=min((abs(m)+abs(M)*2),(abs(m)*2+abs(M)),ans)\n if i+K==N:\n break\n \nprint(ans)\n\n'] | ['Runtime Error', 'Accepted'] | ['s359483249', 's269164562'] | [14692.0, 14480.0] | [362.0, 121.0] | [820, 361] |
p03274 | u799065076 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=list(map(int,input().split()))\nx=list(map(int,input().split()))\nt_min=10**9+7\nfor i in range(N-K+1):\n t=x[i+K-1]-x[i]+min(np.abs(x[i]),np.abs(x[i+K-1]))\n if t<t_min:\n t_min=t\nprint(t_min)', 'import numpy as np\n\nN,K=list(map(int,input().split()))\nx=list(map(int,input().split()))\nt_min=10**9+7\nfor i in range(N-K+1):\n t=x[i+K-1]-x[i]+min(np.abs(x[i]),np.abs(x[i+K-1]))\n if t<t_min:\n t_min=t\nprint(t_min)'] | ['Runtime Error', 'Accepted'] | ['s269344526', 's201058647'] | [14384.0, 23096.0] | [42.0, 478.0] | [204, 224] |
p03274 | u806976856 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nx=list(map(int,input().split()))\na=[x[i] for i in range(n) if x[i]<0]\nb=[x[i] for i in range(n) if x[i]>=0]\nna=len(a)\nnb=len(b)\nif b[0]==0:\n k-=1\n b=[x[i] for i in range(n) if x[i]>0]\n nb=nb-1\nif k==0:\n print(0)\n exit()\nans=10**10\nif na>=k:\n ans=-a[-k]\nif nb>=k:\n ans=min(ans,b[k-1])\nexit()\n', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\na=[x[i] for i in range(n) if x[i]<0]\nb=[x[i] for i in range(n) if x[i]>=0]\nna=len(a)\nnb=len(b)\nif b[0]==0:\n k-=1\n b=[x[i] for i in range(n) if x[i]>0]\n nb=nb-1\nif k==0:\n print(0)\n exit()\nans=10**10\nif na>=k:\n ans=-a[-k]\nif nb>=k:\n ans=min(ans,b[k-1])\nif nb==0:\n print(-a[-k])\n exit()\nif na==0:\n print(b[k-1])\n exit()\nexit()\nfor i in range(1,nb+1):\n m=k-i\n if m>na or m<0:\n continue\n elif 0<m<=na:\n ans=min(ans,min(b[i-1]-2*a[-m],2*b[i-1]-a[-m]))\n elif m==0:\n ans=min(ans,b[k-1])\nprint(ans if k!=0 else 0)\n', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\na=[x[i] for i in range(n) if x[i]<0]\nb=[x[i] for i in range(n) if x[i]>=0]\nna=len(a)\nnb=len(b)\nif b[0]==0:\n k-=1\n b=[x[i] for i in range(n) if x[i]>0]\n nb=nb-1\nif k==0:\n print(0)\n exit()\nans=10**10\nif na>=k:\n ans=-a[-k]\nif nb>=k:\n ans=min(ans,b[k-1])\nif nb==0:\n print(-a[-k])\n exit()\nexit()\nif na==0:\n print(b[k-1])\n exit()\n\nfor i in range(1,nb+1):\n m=k-i\n if m>na or m<0:\n continue\n elif 0<m<=na:\n ans=min(ans,min(b[i-1]-2*a[-m],2*b[i-1]-a[-m]))\n elif m==0:\n ans=min(ans,b[k-1])\nprint(ans if k!=0 else 0)\n', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\na=[x[i] for i in range(n) if x[i]<0]\nb=[x[i] for i in range(n) if x[i]>=0]\nna=len(a)\nnb=len(b)\nif b[0]==0:\n k-=1\n b=[x[i] for i in range(n) if x[i]>0]\n nb=nb-1\nexit()\n', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\na=[x[i] for i in range(n) if x[i]<0]\nb=[x[i] for i in range(n) if x[i]>=0]\nna=len(a)\nnb=len(b)\nif 0 in x:\n k-=1\n b=[x[i] for i in range(n) if x[i]>0]\n nb=nb-1\n\nif k==0:\n print(0)\n exit()\nans=10**10\nif na>=k:\n ans=-a[-k]\n\nif nb>=k:\n ans=min(ans,b[k-1])\n\nif nb==0:\n print(-a[-k])\n exit()\n\nif na==0:\n print(b[k-1])\n exit()\n\nfor i in range(1,nb+1):\n m=k-i\n if m>na or m<0:\n continue\n elif 0<m<=na:\n ans=min(ans,min(b[i-1]-2*a[-m],2*b[i-1]-a[-m]))\n elif m==0:\n ans=min(ans,b[k-1])\nprint(ans if k!=0 else 0)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s192369688', 's346362321', 's424257269', 's493842510', 's328463619'] | [20120.0, 20020.0, 20160.0, 20288.0, 20032.0] | [69.0, 64.0, 64.0, 64.0, 107.0] | [341, 633, 634, 238, 630] |
p03274 | u812576525 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = list(map(int,input().split()))\nA = list(map(int,input().split()))\nP = [0] + [abs(i) for i in A if i> 0 ]\nM = [abs(i) for i in A if i< 0 ] +[0]\nM = sorted(M,reverse =False)\n\nprint(P,M)\ncnt = 10000000\n\nif len(P) == len(M) == 1:\n cnt = 0\nelif len(P) == 1:\n cnt = M[K]\nelif len(M) == 1:\n cnt = P[K]\nelse:\n \n \n \n \n s = max(0,K-len(M)+1)\n e = min(K+1, len(P))\n for i in range(s, e):\n cnt =min(cnt,P[i]*2 + M[K-i])\n \n s1 = max(0,K-len(P)+1)\n e1 = min(K+1, len(M))\n for i in range(s1, e1):\n cnt =min(cnt,M[i]*2 + P[K-i])\n\nprint(cnt)', 'N,K = list(map(int,input().split()))\nX = list(map(int,input().split()))\nans = 10**10\n\nfor i in range(N-K+1):\n #S = X[i:i+K]\n #print(S,S[0],S[-1])\n mi = X[i]\n ma = X[i+K-1]\n #print(mi,ma)\n if ma<=0:\n ans = min(ans ,abs(mi))\n elif mi>0:\n ans = min(ans ,ma)\n elif mi<0 and ma>0:\n if abs(mi) > ma :\n ans = min(ans,abs(mi) + 2*ma)\n else :\n ans = min(ans,abs(mi)*2 + ma)\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s180765520', 's396621211'] | [16400.0, 20192.0] | [106.0, 77.0] | [963, 452] |
p03274 | u812867074 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nli=list(map(int,input().split()))\nq=[]\nfor i in range(k,n):\n if i<0 or i-k+1>0:\n q.append(li[i-1]-li[i-k])\n else:\n q.append(li[i-1]-li[i-k]+min(li[i-1],abs(li[i-k])))\nprint(min(q))\n\n ', 'n,k=map(int,input().split())\nli=list(map(int,input().split()))\nq=[]\nif k==n:\n q.append(li[n-1]-li[0]+min(abs(li[n-1]),abs(li[0])))\nelse:\n for i in range(k,n+1):\n if li[i-1]<0:\n q.append(-li[i-k])\n elif li[i-k]>0:\n q.append(li[i-1])\n else:\n q.append(li[i-1]-li[i-k]+min(li[i-1],abs(li[i-k])))\nprint(min(q))\n'] | ['Runtime Error', 'Accepted'] | ['s864197966', 's482582048'] | [14384.0, 14252.0] | [67.0, 94.0] | [223, 332] |
p03274 | u814781830 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input())\nx = list(map(int, input()))\nret = 10 ** 9\nfor i in range(N-k+1):\n init = abs(x[i])\n dist = abs(x[i]-x[i+k-1])\n l = init + dist\n init = abs(x[i+k-1])\n r = init + dist\n ret = min(l, r)\nprint(ret)', 'N, K = map(int, input().split())\nx = list(map(int, input().split()))\nret = 10 ** 9\nfor i in range(N-K+1):\n init = abs(x[i])\n dist = abs(x[i]-x[i+K-1])\n l = init + dist\n init = abs(x[i+K-1])\n r = init + dist\n ret = min(ret, l, r)\nprint(ret)'] | ['Runtime Error', 'Accepted'] | ['s006767103', 's144733492'] | [3064.0, 14384.0] | [17.0, 96.0] | [236, 257] |
p03274 | u814986259 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nx = list(map(int, input().split()))\n\nplus = [i for i in x if i >= 0]\nminus = [i for i in x if i <= 0]\nid = 0\nfor i in range(N):\n if x[i] >= 0:\n id = i\n break\nans = float("Inf")\nif N - id >= K:\n ans = x[id+K-1]\nif id >= K:\n ans = min(ans, -x[id - K])\nfor i in range(max(0, K-id-1), min(N-id, id)-1):\n ans = min(ans, x[id+i] - x[id-K+1+i]*2)\n ans = min(ans, x[id+i]*2 - x[id-K+1+i])\nprint(ans)\n', 'N, K = map(int, input().split())\nx = list(map(int, input().split()))\n\nplus = [i for i in x if i >= 0]\nminus = [i for i in x if i <= 0]\nid = 0\nfor i in range(N):\n if x[i] >= 0:\n id = i\n break\nans = float("Inf")\nif N - id >= K:\n ans = x[id+K-1]\nif id >= K:\n ans = min(ans, -x[id - K])\nfor i in range(max(0, K-id-1), min(N-id, id)):\n print(i)\n ans = min(ans, x[id+i] - x[id-K+1+i]*2)\n ans = min(ans, x[id+i]*2 - x[id-K+1+i])\nprint(ans)\n', 'N, K = map(int, input().split())\nx = list(map(int, input().split()))\n\nplus = [i for i in x if i >= 0]\nminus = [i for i in x if i <= 0]\nid = 0\nfor i in range(N):\n if x[i] >= 0:\n id = i\n break\nans = float("Inf")\nif N - id >= K:\n ans = x[id+K-1]\nif id >= K:\n ans = min(ans, -x[id - K])\nfor i in range(max(0, K-id-1), min(N-id, id)-1):\n print(i)\n ans = min(ans, x[id+i] - x[id-K+1+i]*2)\n ans = min(ans, x[id+i]*2 - x[id-K+1+i])\nprint(ans)\n', 'N, K = map(int, input().split())\nx = list(map(int, input().split()))\nans = 10**10\nfor i in range(N-K+1):\n ans = min(ans, abs(x[i]) + abs(x[i] - x[i+K-1]))\n ans = min(ans, abs(x[i+K-1]) + abs(x[i+K-1] - x[i]))\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s440871984', 's558170588', 's925182971', 's390501009'] | [14780.0, 14480.0, 14536.0, 14568.0] | [108.0, 142.0, 150.0, 105.0] | [454, 465, 467, 226] |
p03274 | u824237520 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nfor center in range(n):\n if x[center] >= 0:\n break\n\nif center == n or (center == n - 1 and x[n - 1] == 0):\n print(-1 * x[n - k])\n exit()\nelif center == 0:\n print(x[k - 1])\n exit()\n\nplus = [0] + x[center:]\nminus = [0] + list(reversed(list(map(lambda i:i * -1, x[:center]))))\n\nans = 10 ** 10\n\nfor i in range(max(k - len(minus) + 1, 0), min(k + 1, len(plus))):\n ans = min(ans, plus[i] + minus[k - i] + min(plus[i], minus[k - 1]))\n\nprint(ans)', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nfor center in range(n):\n if x[center] >= 0:\n break\n\nif center == n or (center == n - 1 and x[n - 1] == 0):\n print(-1 * x[n - k])\n exit()\nelif center == 0:\n print(x[k - 1])\n exit()\n\nplus = [0] + x[center:]\nminus = [0] + list(reversed(list(map(lambda i:i * -1, x[:center]))))\n\nans = 10 ** 10\n\nfor i in range(max(k - len(minus) + 1, 0), min(k + 1, len(plus))):\n print(i, k - i)\n ans = min(ans, plus[i] + minus[k - i] + min(plus[i], minus[k - i]))\n\nprint(ans)', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nfor center in range(n):\n if x[center] >= 0:\n break\n\nif center == n - 1:\n print(-1 * x[n - k])\n exit()\nelif center == 0:\n print(x[k - 1])\n exit()\n\nplus = [0] + x[center:]\nminus = [0] + list(reversed(list(map(lambda i:i * -1, x[:center]))))\n\nans = 10 ** 10\n\nfor i in range(max(k - len(minus) + 1, 0), min(k + 1, len(plus))):\n ans = min(ans, plus[i] + minus[k - i] + min(plus[i], minus[k - i]))\n\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s309884013', 's534069310', 's635975121'] | [14660.0, 14564.0, 14568.0] | [78.0, 151.0, 88.0] | [533, 553, 498] |
p03274 | u834415466 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=map(int,input().split())\nx=list(map(int,input().split()))\nmin=1000000000\nfor i in range(N-K+1):\n if x[i+K+1]<0:\n if min>-x[i]:\n min=-x[i]\n elif x[i]>=0:\n if min>x[i+K-1]:\n min=x[i+K-1]\n elif x[i]+x[i+K-1]>=0:\n if min>x[i+K-1]-x[i]*2:\n min=x[i+K-1]-x[i]*2\n else:\n if min>x[i+K-1]*2-x[i]:\n min=x[i+K-1]*2-x[i]\nprint(min)', 'N,K=map(int,input().split())\nx=list(map(int,input().split()))\ntmin=1000000000\nfor i in range(N-K+1):\n a=x[i+K-1]\n b=x[i]\n res=a-b+min([abs(a),abs(b)])\n if tmin>a:\n tmin=a\nprint(tmin)', 'N,K=map(int,input().split())\nx=list(map(int,input().split()))\nmin=1000000000\nfor i in range(N-4):\n if x[i+4]<0:\n if min>-x[i]:\n min=-x[i]\n elif x[i]>=0:\n if min>x[i+4]:\n min=x[i+4]\n elif x[i]+x[i+4]>=0:\n if min>x[i+4]-x[i]*2:\n min=x[i+4]-x[i]*2\n else:\n if min>x[i+4]*2-x[i]:\n min=x[i+4]*2-x[i]\nprint(min)\n ', 'N,K=map(int,input().split())\nx=list(map(int,input().split()))\nmin=1000000000\nfor i in range(N-4):\n if x[i+4]<0:\n if min>-x[i]:\n min=x[i]\n elif x[i]>=0:\n if min>x[i+4]:\n min=x[i+4]\n elif x[i]+x[i+4]>=0:\n if min>x[i+4]-x[i]*2:\n min=x[i+4]-x[i]*2\n else:\n if min>x[i+4]*2-x[i]:\n min=x[i+4]*2-x[i]\nprint(min)', 'import bisect\nN,K=map(int,input().split())\nx=list(map(int,input().split()))\nmin=1000000000\n\na=bisect.bisect_left(x,0)\nflist=[]\nfor i in range(a-K,a):\n if i+K-1>N-1 or i<0:\n pass\n else:\n flist.append(i)\n\n\n\n\n\n\n\n\nfor i in flist:\n if x[i+K+1]<0:\n if min>-x[i]:\n min=-x[i]\n elif x[i]>=0:\n if min>x[i+K-1]:\n min=x[i+K-1]\n elif x[i]+x[i+K-1]>=0:\n if min>x[i+K-1]-x[i]*2:\n min=x[i+K-1]-x[i]*2\n else:\n if min>x[i+K-1]*2-x[i]:\n min=x[i+K-1]*2-x[i]\nprint(min)', 'N,K=map(int,input().split())\nx=list(map(int,input().split()))\ntmin=1000000000\nfor i in range(N-K+1):\n a=x[i+K-1]\n b=x[i]\n res=a-b+min([abs(a),abs(b)])\n if tmin>res:\n tmin=res\nprint(tmin)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s326222715', 's649135246', 's693828218', 's789624215', 's932479900', 's506023409'] | [14480.0, 14384.0, 14660.0, 14696.0, 14384.0, 14252.0] | [79.0, 82.0, 75.0, 71.0, 92.0, 84.0] | [406, 201, 393, 387, 552, 205] |
p03274 | u838644735 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ["def main():\n N, K = map(int, input().split())\n X = list(map(int, input().split()))\n D = [0]*(N - 1)\n for i in range(1, N):\n D[i-1] = X[i] - X[i - 1]\n ans = 0\n t = 0\n T = [0]*(N - K + 1)\n for i in range(1, N):\n t += D[i-1]\n if i < K:\n if i == K - 1:\n T[0] = t\n continue\n t -= D[i - K]\n T[i - K + 1] = t\n # print(D, T)\n ans = K * 10**8\n for i in range(N - K + 1):\n a = T[i] + min(abs(X[i]), abs(X[i + K - 1])]\n ans = min(a, ans)\n print(ans)\n\nif __name__ == '__main__':\n main()\n", "def main():\n N, K = map(int, input().split())\n X = list(map(int, input().split()))\n D = [0]*(N - 1)\n for i in range(1, N):\n D[i-1] = X[i] - X[i - 1]\n ans = 0\n t = 0\n T = [0]*(N - K + 1)\n for i in range(1, N):\n t += D[i-1]\n if i < K:\n if i == K - 1:\n T[0] = t\n continue\n t -= D[i - K]\n T[i - K + 1] = t\n # print(D, T)\n ans = K * 10**8\n for i in range(N - K + 1):\n a = T[i] + min(abs(X[i]), abs[X[i + K - 1])]\n ans = min(a, ans)\n print(ans)\n\nif __name__ == '__main__':\n main()\n", "def main():\n N, K = map(int, input().split())\n X = list(map(int, input().split()))\n D = [0]*(N - 1)\n for i in range(1, N):\n D[i-1] = X[i] - X[i - 1]\n ans = 0\n t = 0\n T = [0]*(N - K + 1)\n for i in range(1, N):\n t += D[i-1]\n if i < K:\n if i == K - 1:\n T[0] = t\n continue\n t -= D[i - K]\n T[i - K + 1] = t\n # print(D, T)\n ans = K * 10**8\n for i in range(N - K + 1):\n a = T[i] + min(abs(X[i]), abs(X[i + K - 1]))\n ans = min(a, ans)\n print(ans)\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s271811020', 's476763609', 's667873802'] | [3064.0, 3064.0, 14480.0] | [17.0, 17.0, 121.0] | [600, 600, 600] |
p03274 | u842964692 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=[int(i) for i in input().split()]\nX=[int(i) for i in input().split()]\nm=10**5\nfor i in range(N-K+1):\n m=min(m,x[K-1+i]-x[i]+min(abs(x[K-1+i]),abs(x[i])))\n\nprint(m)', 'N,K=map(int,input().split())\n\nx=list(map(int,input().split()))\n\nxm=[]\nxp=[]\nx0=[]\nans=10**5+1\n\nfor i in range(N):\n xi=x[i]\n if xi<0:\n xm.append(xi)\n elif xi==0:\n x0.append(xi)\n else:\n xp.append(xi)\n\nxm.sort(reverse=True)\n\nif x0==[]:\n ajst=0\nelse:\n ajst=1\n\nK=K-ajst\n\nfor i in range(min(len(xp),K)):\n if i<K-1:\n if len(xm)>=K-(i+1):\n ans=min(ans,2*xp[i]-xm[K-ajst-(i+1)-1])\n \n else:#i==K-1\n ans=min(ans,xp[i])\n\nfor i in range(min(len(xm),K)):\n if i<K-1:\n if len(xp)-1>=K-(i+1):\n ans=min(ans,-2*xm[i]+xp[K-ajst-(i+1)-1])\n \n else:#i==K-1\n ans=min(ans,-xm[i])\n\nif K==1 and x0!=[]:\n ans=0\n\nprint(ans)', 'N,K=map(int,input().split())\n\nx=list(map(int,input().split()))\n\nxm=[]\nxp=[]\nx0=[]\nans=10**5+1\n\nfor i in range(N):\n xi=x[i]\n if xi<0:\n xm.append(xi)\n elif xi==0:\n x0.append(xi)\n else:\n xp.append(xi)\n\nxm.sort(reverse=True)\n\nif x0==[]:\n ajst=0\nelse:\n ajst=1\n\nK=K-ajst\n\nfor i in range(min(len(xp),K)):\n if i<K-1:\n if len(xm)>=K-(i+1):\n ans=min(ans,2*xp[i]-xm[K-ajst-(i+1)-1])\n \n else:#i==K-1\n ans=min(ans,xp[i])\n\nfor i in range(min(len(xm),K)):\n if i<K-1:\n if len(xp)-1>=K-(i+1):\n ans=min(ans,-2*xm[i]+xp[K-ajst-(i+1)-1])\n \n else:#i==K-1\n ans=min(ans,-xm[i])\n\nif K==1 and x0!=0:\n ans=0\n\nprint(ans)', 'N,K=[int(i) for i in input().split()]\nX=[int(i) for i in input().split()]\nm=10**5\nfor i in range(n-k+1):\n m=min(m,x[k-1+i]-x[i]+min(abs(x[k-1+i]),abs(x[i])))\n\nprint(m)', 'N,K=[int(i) for i in input().split()]\nX=[int(i) for i in input().split()]\nm=10**9\nfor i in range(N-K+1):\n m=min(m,X[K-1+i]-X[i]+min(abs(X[K-1+i]),abs(X[i])))\n\nprint(m)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s050550488', 's175105124', 's268403992', 's270211248', 's348476496'] | [14252.0, 3064.0, 3064.0, 14384.0, 14384.0] | [47.0, 17.0, 17.0, 46.0, 92.0] | [170, 706, 705, 170, 170] |
p03274 | u843774833 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['# coding: utf-8\nimport sys\n\ndef getMin(X, K):\n minVal = sys.maxsize\n if K == 1:\n return X[0]\n \n for l in range(0, len(X)-K):\n minVal = min(minVal, abs(X[l]) + abs(X[K + l - 1] - X[l]))\n \n return minVal\n\ndef solve(X, K):\n ans = min(getMin(X, K), getMin(X[::-1], K))\n return ans\n\nif __name__ == "__main__":\n N, K = map(int, input().split())\n X = map(int, input().split())\n print(solve(X, K))\n\n', '# coding: utf-8\n\ndef getMin(X, K):\n minVal = float(\'inf\')\n for l in range(len(X)-K+1): \n minVal = min(minVal, abs(X[l]) + abs(X[K + l - 1] - X[l]))\n minVal = min(minVal, abs(X[K + l - 1]) + abs(X[l] - X[K + l - 1]))\n return minVal\n\nif __name__ == "__main__":\n N, K = map(int, input().split())\n X = list(map(int, input().split()))\n print(getMin(X, K))\n\n'] | ['Runtime Error', 'Accepted'] | ['s374198507', 's782948414'] | [11480.0, 14380.0] | [29.0, 93.0] | [446, 391] |
p03274 | u845620905 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = map(int, input().split())\nx = list(map(int, input().split()))\nans = 1e13\nfor i in range(n-k+1):\n l = x[i]\n r = x[i+k]\n ans = min(ans, abs(l)+abs(r-l))\nprint(ans)\n', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\nans = 1e13\nfor i in range(n-k):\n l = x[i]\n r = x[i+k-1]\n if(l <= 0):\n ans = min(ans, abs(r) + abs(l - r))\n else:\n ans = min(ans, abs(l)+abs(r-l))\nprint(ans)\n', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\nans = 1e13\nfor i in range(n-k+1):\n l = x[i]\n r = x[i+k-1]\n ans = min(ans, abs(r)+abs(l-r))\n ans = min(ans, abs(l)+abs(r-l))\nprint(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s898775735', 's909042304', 's514336073'] | [14224.0, 14252.0, 14384.0] | [76.0, 80.0, 93.0] | [178, 252, 216] |
p03274 | u853900545 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import bisect\nn,k = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nzero = bisect.bisect_left(a,0)\ncnt = min(-sum(a[zero-k-1:zero]),sum(a[zero:zero+k+1]))\nfor i in range(1,k):\n if cnt > -2*a[zero-i]+a[zero+k]:\n cnt = -2*a[zero-i]+a[zero+k]\n else:\n break\nfor i in range(1,k):\n if cnt > -a[zero-k+i]+2*a[zero+k]:\n cnt = -a[zero-k+i]+2*a[zero+k]\n else:\n break\nprint(cnt)', 'import bisect\nn,k = map(int,input().split())\na = list(map(int,input().split()))\ncnt = 0\na.sort()\nzero = bisect.bisect_left(a,0)\nfor i in range(zero):\n if cnt > -2*sum(a[0:zero])+sum(a[zero:n-zero]):\n cnt = -2*sum(a[0:zero])+sum(a[zero:n-zero])\n else:\n break\nfor i in range(zero):\n if cnt > -sum(a[0:zero])+2*sum(a[zero:n-zero]):\n cnt = -sum(a[0:zero])+2*sum(a[zero:n-zero])\n else:\n break\nprint(c)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k+1):\n c=min(c,abs(a[i]+a[i+k-1]\\\n -abs(min(a[i],a[i+k-1]))))\nprint(c)\n', 'import bisect\nn,k = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nzero = bisect.bisect_left(a,0)\ncnt = min(-sum(a[zero-k+1:zero]),sum(a[zero:zero+k+1]))\nfor i in range(1,k):\n if cnt > -2*a[zero-i]+a[zero+k]:\n cnt = -2*a[zero-i]+a[zero+k]\n else:\n break\nfor i in range(1,k):\n if cnt > -a[zero-k+i]+2*a[zero+k]:\n cnt = -a[zero-k+i]+2*a[zero+k]\n else:\n break\nprint(cnt)', 'import bisect\nn,k = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nzero = bisect.bisect_left(a,0)\ncnt = (10**8)*(10**5)\ncnt = min(sum(a[zero:n]),-sum(a[0:zero]))\nfor i in range(1,zero):\n if cnt > -2*a[zero-i]+a[n-1-i]:\n cnt = -2*a[zero-i]+a[n-1-i]\n else:\n break\nfor i in range(1,zero):\n if cnt > -a[i]+2*a[zero+i-1]:\n cnt = -a[i]+2*a[zero+i-1]\n else:\n break\nprint(cnt)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k):\n c=min(c,a[i]+a[i+k-1]-abs(min(a[i],a[i+k-1])))\nprint(c)', 'import bisect\nn,k = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nzero = bisect.bisect_left(a,0)\ncnt = min(-sum(a[zero-k:zero]),sum(a[zero:zero+k+1]))\nfor i in range(1,k):\n if cnt > -2*a[zero-i]+a[zero+k-i-1]:\n cnt = -2*a[zero-i]+a[zero+k-i-1]\n else:\n break\nfor i in range(1,k):\n if cnt > -a[zero-k+i]+2*a[zero+k-1]:\n cnt = -a[zero-k+i]+2*a[zero+k-1]\n else:\n break\nprint(cnt)', 'import bisect\nn,k = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nzero = bisect.bisect_left(a,0)\nZ = min(n-zero,zero,k)\ncnt = (10**8)*(10**5)\nfor i in range(Z):\n if cnt > -2*a[zero-i]+a[zero+k-i-1]:\n cnt = -2*a[zero-i]+a[zero+k-i-1]\n else:\n break\nfor i in range(Z):\n if cnt > -a[zero-k+i]+2*a[zero+i-1]:\n cnt = -a[zero-k+i]+2*a[zero+i-1]\n else:\n break\nprint(cnt)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k+1):\n c=min(c,-abs(a[i]+a[i+k-1]\\\n +min(abs(a[i]),abs(a[i+k-1]))))\nprint(c)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k+1):\n c=min(c,abs(a[i]+a[i+k-1]\\\n -min(abs(a[i]),abs(a[i+k-1]))))\nprint(c)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k+1):\n c=min(c,a[i]+a[i+k-1]\\\n -abs(min(a[i],a[i+k-1])))\nprint(c)\n', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k+1):\n c=min(c,abs(a[i]+a[i+k-1]\\\n -min(abs(a[i]),abs(a[i+k-1]))))\nprint(c)\n', 'import bisect\nn,k = map(int,input().split())\na = list(map(int,input().split()))\na.sort()\nzero = bisect.bisect_left(a,0)\nZ = min(n-zero,zero,k)\ncnt = min(-sum(a[Z-k:zero]),sum(a[zero:zero+Z]))\nfor i in range(1,k):\n if cnt > -2*a[zero-i]+a[zero+k-i-1]:\n cnt = -2*a[zero-i]+a[zero+k-i-1]\n else:\n break\nfor i in range(1,k):\n if cnt > -a[zero-k+i]+2*a[zero+i-1]:\n cnt = -a[zero-k+i]+2*a[zero+i-1]\n else:\n break', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k):\n c=min(c,a[i]+a[i+k])\nprint(c)', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\nc=10**10\nfor i in range(n-k+1):\n c=min(c,-a[i]+a[i+k-1]\\\n +min(abs(a[i]),abs(a[i+k-1])))\nprint(c)\n'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s026045126', 's026658898', 's110263318', 's207046151', 's217727138', 's250230630', 's334618717', 's420305801', 's564385029', 's566255543', 's641639835', 's876962609', 's920675713', 's952153655', 's828362401'] | [14480.0, 14548.0, 14224.0, 14480.0, 14660.0, 14252.0, 14548.0, 14544.0, 14384.0, 14224.0, 14252.0, 15020.0, 14568.0, 15020.0, 14224.0] | [45.0, 47.0, 88.0, 47.0, 46.0, 85.0, 45.0, 46.0, 98.0, 91.0, 84.0, 91.0, 47.0, 64.0, 88.0] | [428, 436, 171, 428, 430, 151, 438, 425, 176, 176, 166, 176, 445, 125, 172] |
p03274 | u853952087 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n=list(map(int,input().split()))\nY=list(map(int,input().split()))\nP=[i for i in Y if i>=0]\nM=[i*-1 for i in Y if i<0]\nif P==[]:\n P.append(max(M)*1000)\nif M==[]:\n M.append(max(P)*1000)\np=sorted(P)\nm=sorted(M)\nprint(p,m)\nL1=[]\nL2=[]\nfor i in range(n[1]):\n if n[1]-i-2<len(m) and i<len(p):\n L1.append(p[i]+m[n[1]-i-2]*2)\n L2.append(p[i]*2+m[n[1]-i-2])\nif len(p)>n[1]:\n L1.append(p[n[1]-1])\nif len(m)>n[1]:\n L2.append(m[n[1]-1])\nprint(min(min(L1),min(L2)))', 'n=list(map(int,input().split()))\nY=list(map(int,input().split()))\nP=[i for i in Y if i>=0]\nM=[i*-1 for i in Y if i<0]\n\nif P==[]:\n P.append(max(M)*1000)\nif M==[]:\n M.append(max(P)*1000)\np=sorted(P)\nm=sorted(M)\nL1=[]\nL2=[]\n\nfor i in range(n[1]):\n if n[1]-i-2<len(m) and i<len(p):\n L1.append(p[i]+m[n[1]-i-2]*2)\n L2.append(p[i]*2+m[n[1]-i-2])\nif len(p)>=n[1]:\n L1.append(p[n[1]-1])\nif len(m)>=n[1]:\n L2.append(m[n[1]-1])\nprint(min(min(L1),min(L2)))'] | ['Wrong Answer', 'Accepted'] | ['s353355389', 's297778085'] | [16016.0, 14480.0] | [118.0, 118.0] | [481, 616] |
p03274 | u856232850 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k = map(int,input().split())\n\nx = list(map(int,input().split()))\nans = 100000000000000\n\n\nfor i in range(n-k+1):\n\tif x[i+k-1] <= 0:\n\t\tans = min(ans,-x[i])\n\telif x[i] >= 0:\n\t\tans = min(x[i+k-1],ans)\n\telse:\n\t\tans = min(x[i+k-1]-x[i]+min(abs(x[i]),x[i+k-1]))\nprint(ans)', 'n,k = map(int,input().split())\n\nx = list(map(int,input().split()))\nans = 100000000000000\n\na = 0\nwhile a != n:\n\tif x[a] >= 0:\n\t\tbreak\n\ta += 1\nfor i in range(max(0,a-k),n-k+1):\n\tif x[i+k-1] <= 0:\n\t\tans = min(ans,-x[i])\n\telif x[i] >= 0:\n\t\tans = min(x[i+k-1],ans)\n\telse:\n\t\tans = min(x[i+k-1]-x[i]+min(-x[i],x[i+k-1]),ans)\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s135754767', 's334960659'] | [14224.0, 14224.0] | [67.0, 102.0] | [267, 328] |
p03274 | u858136677 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k = map(int,input().split())\nx = list(map(int,input().split()))\n\nl = 0\nr = k-1\nmnm = 1000100010\nwhile r<n:\n print(r)\n a = abs(x[l])+abs(x[l]-x[r])\n b = abs(x[r])+abs(x[r]-x[l])\n if a<=b:\n if a < mnm:\n mnm = a\n else:\n if b < mnm:\n mnm = b\n l += 1\n r += 1\nprint(mnm)', 'n,k = map(int,input().split())\nx = list(map(int,input().split()))\n\nl = 0\nr = k-1\nmnm = 1000100010\nwhile r<n:\n a = abs(x[l])+abs(x[l]-x[r])\n b = abs(x[r])+abs(x[r]-x[l])\n if a<=b:\n if a < mnm:\n mnm = a\n else:\n if b < mnm:\n mnm = b\n l += 1\n r += 1\nprint(mnm)'] | ['Wrong Answer', 'Accepted'] | ['s954325756', 's423821781'] | [14532.0, 15020.0] | [128.0, 88.0] | [323, 310] |
p03274 | u860002137 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nans = []\nfor i in range(n - k + 1):\n left = x[i]\n right = x[i + k - 1]\n elif abs(left) > abs(right):\n ans.append(abs(right) + abs(left - right))\n else:\n ans.append(abs(left) + abs(right - left))\n\nprint(min(ans))', 'import numpy as np\nn, k = map(int, input().split())\nx = np.array(list(map(int, input().split())))\n\nans = []\nfor i in range(n - k + 1):\n left = 0\n right = 0\n arr = x[i: i + k]\n if arr.min() < 0:\n left = arr.min()\n if arr.max() >= 0:\n right = arr.max()\n ans.append(min(left * 2 + right, left + right * 2))\n\nprint(min(ans))', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nans = []\nfor i in range(n - k + 1):\n left = x[i]\n right = x[i + k - 1]\n if abs(left) > abs(right):\n ans.append(abs(right) + abs(left - right))\n else:\n ans.append(abs(left) + abs(right - left))\n\nprint(min(ans))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s383203112', 's444854622', 's492934019'] | [2940.0, 23088.0, 14252.0] | [17.0, 2109.0, 77.0] | [307, 352, 305] |
p03274 | u860657719 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['H, W = map(int, input().split())\na = []\nfor i in range(H):\n a.append(input())\nrow = [False]*H\ncol = [False]*W\nfor i in range(H):\n for j in range(W):\n if a[i][j] == "#":\n row[i] = True\n col[j] = True\nfor i in range(H):\n if row[i]:\n for j in range(W):\n if col[j]:\n print(a[i][j], end = "")\n print("", end = "\\n")\n', 'N, K = map(int, input().split())\nx = [int(i) for i in input().split()]\nmintime = 1e9\nfor i in range(N-K+1):\n time1 = abs(x[i])+x[i+K-1]-x[i]\n time2 = abs(x[i+K-1])+x[i+K-1]-x[i]\n time = min([time1,time2])\n if time < mintime:\n mintime = time\nprint(mintime)\n'] | ['Runtime Error', 'Accepted'] | ['s423299665', 's480407334'] | [5452.0, 14224.0] | [19.0, 106.0] | [389, 275] |
p03274 | u865413330 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import sys\n\nN, K = map(int, input().split())\ncandles = list(map(int, input().split()))\n\ntmp = sys.maxsize\n\nfor i in range(K):\n minNum = candles[i]\n maxNum = candles[i+K]\n if minNum >= 0 and maxNum >= 0:\n ans = maxNum\n elif maxNum >= 0 and minNum < 0:\n a = 2 * abs(minNum) + maxNum\n b = 2 * maxNum + abs(minNum)\n ans = min(a,b)\n elif maxNum < 0 and minNum < 0:\n ans = abs(minNum)\n tmp = min(ans, tmp)\n\nprint(tmp)', 'N, K = map(int, input().split())\ncandles = list(map(int, input().split()))\n\nfor i in range(K):\n minNum = candles[i]', 'N, K = map(int, input().split())\ncandles = list(map(int, input().split()))\n\nfor i in range(N-K+1):\n minNum = candles[i]\n maxNum = candles[i+K-1]', 'import sys\n\nN, K = map(int, input().split())\ncandles = list(map(int, input().split()))\n\ntmp = sys.maxsize\n\nfor i in range(K):\n minNum = candles[i]\n maxNum = candles[i+K-1]\n\nprint(tmp)', 'import sys\n\nN, K = map(int, input().split())\ncandles = list(map(int, input().split()))\n\ntmp = sys.maxsize\n\nfor i in range(K):\n minNum = candles[i]\n maxNum = candles[i+K]\n if maxNum < 0:\n ans = minNum\n elif (minNum < 0) and (0 <= maxNum):\n if abs(minNum) <= abs(maxNum):\n ans = 2*abs(minNum) + maxNum\n else:\n ans = 2*maxNum + abs(minNum)\n elif 0 <= minNum:\n ans = maxNum\n tmp = min(tmp,ans)\n\nprint(tmp)', 'N, K = map(int, input().split())\ncandles = list(map(int, input().split()))\n\nfor i in range(K):\n minNum = candles[i]\n maxNum = candles[i+K-1]', 'import sys\n\nN, K = map(int, input().split())\ncandles = list(map(int, input().split()))\n\nans = sys.maxsize\n\nfor i in range(N-K+1):\n minNum = candles[i]\n maxNum = candles[i+K-1]\n l = abs(minNum) + abs(minNum - maxNum)\n r = abs(maxNum) + abs(maxNum - minNum)\n ans = min(ans, min(l, r))\n\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s091722915', 's613400745', 's613705954', 's781340823', 's790095037', 's919878024', 's786501350'] | [14224.0, 14252.0, 14224.0, 14252.0, 14224.0, 14224.0, 14252.0] | [96.0, 50.0, 54.0, 54.0, 85.0, 53.0, 95.0] | [464, 118, 150, 189, 469, 146, 309] |
p03274 | u875361824 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['def main():\n \n N, K = map(int, input().split())\n * x, = map(int, input().split())\n ans = f(N, K, x)\n print(ans)\n\n\ndef f1(N, K, x):\n \n\n\ndef f(N, K, x):\n l, r = 0, 0\n for i in range(N-1):\n if x[i] == 0:\n l, r = i, i\n break\n elif [i+1] == 0:\n l, r = i+1, i+1\n break\n elif x[i] < 0 < x[i+1]:\n l, r = i, i+1\n break\n\n ans = float("inf")\n \n # print((l, r))\n for i in range(l+1):\n t = abs(x[i])\n right = -1\n rem = 0\n fire = abs(i - l) + 1\n if fire == K:\n ans = min(ans, abs(x[i]))\n elif fire > K:\n # out of index\n pass\n else:\n \n t *= 2\n rem = K - fire\n right = l + rem\n if right < N:\n ans = min(ans, t + x[right])\n\n # print(i, l, right, fire, rem, ans, sep="\\t")\n\n \n # print("----right----")\n for i in range(l, N):\n t = abs(x[i])\n fire = abs(i - r) + 1\n rem = 0\n left = -1\n if fire == K:\n ans = min(ans, abs(x[i]))\n elif fire > K:\n # out of index\n pass\n else:\n \n t *= 2\n rem = K - fire\n left = l - rem\n if left >= 0:\n ans = min(ans, t + abs(x[left]))\n\n # print(left, i, r, fire, rem, ans, sep="\\t")\n\n return ans\n\n\nif __name__ == \'__main__\':\n main()\n', 'def main():\n \n N, K = map(int, input().split())\n *x, = map(int, input().split())\n # ans = WA(N, K, x)\n ans = editorial(N, K, x)\n print(ans)\n\n\ndef editorial(N, K, x):\n from bisect import bisect_left\n try:\n # N=7,K=3\n # [-3,-2,-1,0,1,2,3]\n # |----*---|\n idx = x.index(0)\n left = max(idx - K + 1, 0)\n right = min(idx + 1, N - K)\n except:\n # N=6,K=3\n # [-3,-2,-1,1,2,3]\n # |-----|*|---|\n idx = bisect_left(x, 0)\n left = max(idx - K, 0)\n right = min(idx + 1, N - K)\n\n _range = range(left, right + 1)\n # print(idx, _range)\n ans = float("inf")\n for left in _range:\n right = left + K - 1\n # print(left, right)\n a1 = abs(x[left]) + abs(x[right] - x[left])\n a2 = abs(x[right]) + abs(x[left] - x[right])\n ans = min([ans, a1, a2])\n\n return ans\n\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s930354611', 's531840928'] | [14128.0, 14660.0] | [128.0, 80.0] | [2011, 1046] |
p03274 | u875769753 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import sys\nN,K = map(int,input().split())\nlsx = list(map(int,input().split()))\nif 0 in lsx:\n K = K-1\n lsx.remove(0)\nif bool(lsx) == False or K == 0:\n print(0)\n sys.exit()\nlshu = []\nfor i in range(len(lsx)):\n if lsx[i] < 0:\n lshu.append(lsx[i])\n else:\n sei = i\n break\nlssei = lsx[sei:]\nlenhu = len(lshu)\nlensei = len(lssei)\nlshu2 = [abs(lshu[i]) for i in range(lenhu-1,-1,-1)]\ndishu = [0] + lshu2\ndissei = [0] + lssei\nprint(dissei,dishu)\nans = 10*10**8\nfor i in range(K):\n if i <= lenhu and K-i <= lensei:\n ans = min(ans,2*dishu[i]+dissei[K-i],dishu[i]+2*dissei[K-i])\nprint(ans)', 'import sys\nN,K = map(int,input().split())\nlsx = list(map(int,input().split()))\nif 0 in lsx:\n K = K-1\n lsx.remove(0)\nif bool(lsx) == False or K == 0:\n print(0)\n sys.exit()\nlshu = []\nsei = len(lsx)\nfor i in range(len(lsx)):\n if lsx[i] < 0:\n lshu.append(lsx[i])\n else:\n sei = i\n break\nlssei = lsx[sei:]\nlenhu = len(lshu)\nlensei = len(lssei)\nlshu2 = [abs(lshu[i]) for i in range(lenhu-1,-1,-1)]\ndishu = [0] + lshu2\ndissei = [0] + lssei\nans = 10*10**8\nfor i in range(K+1):\n if i <= lenhu and K-i <= lensei:\n ans = min(ans,2*dishu[i]+dissei[K-i],dishu[i]+2*dissei[K-i])\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s330046694', 's749307946'] | [20024.0, 20096.0] | [101.0, 94.0] | [626, 623] |
p03274 | u887207211 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int,input().split())\nX = list(map(int,input().split()))\n\nans = 1e9\nfor l, r in zip(X, X[K:]):\n ans = min(ans, r-l+min(abs(l),abs(r)))\nprint(ans)', 'N, K = map(int,input().split())\nX = list(map(int,input().split()))\n\nans = 1e9\nfor l, r in zip(X, X[K-1:]):\n ans = min(ans, r-l+min(abs(l),abs(r)))\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s424546345', 's261854182'] | [14388.0, 14224.0] | [75.0, 78.0] | [156, 158] |
p03274 | u888092736 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nX = list(map(int, input().split()))\nans = float("inf")\nfor i in range(N - K + 1):\n left, right = X[i], X[i + K - 1]\n dist = right - left\n ans = min(abs(left) + dist, abs(right) + dist)\nprint(ans)\n', 'N, K = map(int, input().split())\nX = list(map(int, input().split()))\nans = float("inf")\nfor i in range(N - K + 1):\n left, right = X[i], X[i + K - 1]\n dist = right - left\n ans = min(ans, abs(left) + dist, abs(right) + dist)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s856927560', 's965536178'] | [14252.0, 14392.0] | [85.0, 84.0] | [238, 243] |
p03274 | u903005414 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nA = list(map(int, input().split()))\nans = ((N - 1) + (K - 1 - 1)) // (K - 1)\nprint(ans)\n', "N, K = map(int, input().split())\nX = list(map(int, input().split()))\n\nans = 10**18\nfor i in range(N - K + 1):\n d1 = X[i + K - 1] - X[i] + abs(X[i])\n d2 = X[i + K - 1] - X[i] + abs(X[i + K - 1])\n # print('d', d)\n ans = min(ans, d1, d2)\nprint(ans)\n"] | ['Runtime Error', 'Accepted'] | ['s983691852', 's165074331'] | [14252.0, 14384.0] | [42.0, 90.0] | [121, 258] |
p03274 | u905582793 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ["N, K = map(int, input().split(' '))\na= list(map(int, input().split(' ')))\n\nINF = float('inf')\nans = INF\n\nif N == K:\n ans = abs(a[N-1]-a[0])+min(abs(a[0]), abs(a[N-1]))\nelse:\n for i in range(N-K+1):\n ans = min(ans, abs(a[i+K-1]-a[i])+min(abs(a[i+K-1]), abs(a[i])))\n print(a[i+K-1], a[i], ans)\n\nprint(ans)", "N, K = map(int, input().split(' '))\na= list(map(int, input().split(' ')))\n\nINF = float('inf')\nans = INF\n\nif N == K:\n ans = abs(a[N-1]-a[0])+min(abs(a[0]), abs(a[N-1]))\nelse:\n for i in range(N-K+1):\n ans = min(ans, abs(a[i+K-1]-a[i])+min(abs(a[i+K-1]), abs(a[i])))\n\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s769135554', 's610646059'] | [14252.0, 14224.0] | [182.0, 89.0] | [323, 288] |
p03274 | u918601425 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=[int(s) for s in input().split()]\nls_p=[int(s) for s in input().split()]\nls_n=[]\nX=0\nfor i in range(N):\n if ls_p[0]>=0 : break \n else:\n X+=1\n ls_n.append(ls_p[0])\n ls_p.pop(0)\nprint(ls_n)\nprint(ls_p)\n\ncand=[]\nfor i in range(min([X-1,K-2])):\n cand.append(-ls_n[-i-1]*2+ls_p[K-i-2])\n cand.append(-ls_n[-i-1]+ls_p[K-i-2]*2)\nif N-X-1>=K-1:\n cand.append(ls_p[K-1])\nif X>=K:\n cand.append(-ls_n[-K])\nprint(min(cand))\n ', 'N,K=[int(s) for s in input().split()]\nls=[int(s) for s in input().split()]\ndef length(i):\n if ls[i]>=0:\n return ls[K+i-1]\n elif ls[K+i-1]<=0:\n return -ls[i]\n else:\n return min([2*ls[K+i-1]-ls[i],ls[K+i-1]-2*ls[i]])\nanswer=[]\nfor i in range(N-K+1):\n answer.append(length(i))\n \nprint(min(answer))\n '] | ['Runtime Error', 'Accepted'] | ['s312133562', 's482655303'] | [14480.0, 14224.0] | [1569.0, 94.0] | [458, 313] |
p03274 | u922487073 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['\nnear = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])\nbet = abs(xlist[lpos] - xlist[rpos])\n\nans = bet + near\n\nfor i in range(N-K):\n lpos += 1\n rpos += 1\n\n near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])\n bet = abs(xlist[lpos] - xlist[rpos])\n\n tmp = bet+near\n\n if tmp < ans:\n ans = tmp\n\n\nprint(ans)\n', 'N, K = map(int, input().split())\nxlist = list(map(int, input().split()))\n\nlpos = 0\nrpos = K-1\n\nnear = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])\nbet = abs(xlist[lpos] - xlist[rpos])\n\nans = bet + near\n\nfor i in range(N-K):\n lpos += 1\n rpos += 1\n\n near = abs(xlist[lpos]) if (abs(xlist[lpos]) < abs(xlist[rpos])) else abs(xlist[rpos])\n bet = abs(xlist[lpos] - xlist[rpos])\n\n tmp = bet+near\n\n if tmp < ans:\n ans = tmp\n\n\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s090192130', 's868359556'] | [3064.0, 14844.0] | [17.0, 87.0] | [396, 490] |
p03274 | u923279197 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nx=list(map(int,input().split()))\nfor i in range(n-k+1):\n if i==0:\n a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))\n else:\n a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))\nprint(a)', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\nfor i in range(n-k+1):\n if i==0:\n a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))\n else:\n a=min(ans,min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1])))\nprint(a)', 'n,k=map(int,input().split())\nx=list(map(int,input().split()))\nfor i in range(n-k+1):\n if i==0:\n a=min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1]))\n else:\n a=min(a,min(abs(x[i])+abs(x[i]-x[i+k-1]),abs(x[i+k-1])+abs(x[i]-x[i+k-1])))\nprint(a)'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s288478010', 's959027752', 's667106147'] | [14224.0, 14252.0, 14252.0] | [94.0, 42.0, 102.0] | [270, 279, 277] |
p03274 | u926024306 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['a,b=input().split("\\n")\nn,k=a.split(" ")\nx=b.split(" ")\nt=0\ntmin=2*(x[n-1]-x[0])\nfor i in range (0,n-k+1):\n if x[i]>=0:\n t=x[i+k-1]\n else:\n if x[i+k-1]<=0:\n t=abs(x[i])\n else:\n if -1*x[i]<x[i+k-1]:\n t=-2*x[i]+x[i+k-1]\n else:\n t=-1*x[i]+2*x[i+k-1]\n if t<tmin:\n tmin=t\nprint(tmin)', 'n,k=list(map(int, input().split()))\nx=list(map(int, input().split()))\nt=0\ntmin=2*(x[n-1]-x[0])\nfor i in range (0,n-k+1):\n if x[i]>=0:\n t=x[i+k-1]\n else:\n if x[i+k-1]<=0:\n t=abs(x[i])\n else:\n if -1*x[i]<x[i+k-1]:\n t=-2*x[i]+x[i+k-1]\n else:\n t=-1*x[i]+2*x[i+k-1]\n if t<tmin:\n tmin=t\nprint(tmin)'] | ['Runtime Error', 'Accepted'] | ['s406072348', 's053637479'] | [3064.0, 14660.0] | [18.0, 80.0] | [378, 392] |
p03274 | u927534107 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nl=list(map(int,input().split()))\nINF=10**9+7\nif 0 in l:k=k-1\nlm=[0]+[i for i in l if i<0][::-1]\nif len(lm)<k+1:\n lm=lm+[-INF]*(k+1-len(lm))\nlp=[0]+[i for i in l if i>0]\nif len(lp)<k+1:\n lp=lp+[INF]*(k+1-len(lp))\nans=INF*10\nfor i in range(k+1):\n tmp=min(2*lp[i]-lm[k-i],lp[i]-2*lm[k-i])\n print(tmp)\n if tmp<ans:ans=tmp\nprint(ans)', 'n,k=map(int,input().split())\nl=list(map(int,input().split()))\nINF=10**9+7\nif 0 in l:k=k-1\nlm=[0]+[i for i in l if i<0][::-1]\nif len(lm)<k+1:\n lm=lm+[-INF]*(k+1-len(lm))\nlp=[0]+[i for i in l if i>0]\nif len(lp)<k+1:\n lp=lp+[INF]*(k+1-len(lp))\nans=INF*10\nfor i in range(k+1):\n tmp=min(2*lp[i]-lm[k-i],lp[i]-2*lm[k-i])\n if tmp<ans:ans=tmp\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s944677841', 's625853963'] | [14480.0, 14532.0] | [204.0, 124.0] | [372, 357] |
p03274 | u932868243 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nl=list(map(int,input().split()))\nans=[]\nfor i in range(n-k+1):\n ans.append(min(abs(l[i])+abs([l[i]-l[i+k-1]),abs(l[i+k-1])+abs(l[i+k-1]-l[i])))\nprint(min(ans))', 'n,k=map(int,input().split())\nl=list(map(int,input().split()))\nif l[0]<=0 and l[k-1]<=0:\n print(abs(l[0]))\nelif l[0]>=0 and l[k-1]>=0:\n print(l[k-1])\nelse:\n mi=min(l[k-1],abs(l[0]))\n ma=max(l[k-1],abs(l[0]))\n print(mi*2+ma)\n \n ', 'n,k=map(int,input().split())\nl=list(map(int,input().split()))\nans=[]\nfor i in range(n-k+1):\n ans.append(min(abs(l[i])+abs(l[i]-l[i+k-1]),abs(l[i+k-1])+abs(l[i+k-1]-l[i])))\nprint(min(ans))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s401738856', 's428215763', 's807019470'] | [2940.0, 14252.0, 14224.0] | [17.0, 42.0, 97.0] | [189, 234, 188] |
p03274 | u934868410 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k = map(int, input().split())\nx = list(map(int, input().split()))\n\nans = 1000000000\nfor i in range(n-k+1):\n if x[i] * x[i+k-1] < 0:\n ans = min(ans, min(abs(x[i]), abs(x[i+k-1]))*2 + max(abs(x[i]), abs(x[i+k-1])))\n else:\n ans = max(abs(x[i]), abs(x[i+k-1]))\n \nprint(ans)', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\n\nans = 1000000000\nfor i in range(n - k + 1):\n if x[i] * x[i + k - 1] < 0:\n ans = min(ans, min(abs(x[i]), abs(x[i + k - 1])) * 2 + max(abs(x[i]), abs(x[i + k - 1])))\n else:\n ans = min(ans, max(abs(x[i]), abs(x[i + k - 1])))\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s591898874', 's723793861'] | [14224.0, 14384.0] | [109.0, 108.0] | [282, 323] |
p03274 | u941753895 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n n,k=LI()\n l=LI()\n\n if n==1 and k==1 and l[0]==0:\n exit()\n\n if l.count(0)>0:\n k-=1\n l.remove(0)\n\n if k==0:\n print(0)\n exit()\n\n if len(l)==0:\n print(0)\n exit()\n\n idx=len(l)-1\n for i in range(len(l)):\n if l[i]>0:\n idx=i\n break\n if min(l)<0:\n idx=len(l)\n\n l1=[abs(x) for x in l[idx:]]\n l2=[abs(x) for x in l[:idx]]\n l2.reverse()\n\n # print(l1)\n # print(l2)\n\n mn=inf\n for i in range(len(l1)):\n if i+1>=k:\n mn=min(mn,l1[i])\n else:\n if len(l2)>=k-(i+1):\n # print(l1[i],l2[k-(i+1)-1])\n mn=min(mn,l1[i]+2*l2[k-(i+1)-1])\n\n for i in range(len(l2)):\n if i+1>=k:\n mn=min(mn,l2[i])\n else:\n if len(l1)>=k-(i+1):\n # print(l2[i],l1[k-(i+1)-1])\n mn=min(mn,l2[i]+2*l1[k-(i+1)-1])\n\n print(mn)\n\nmain()\n# print(main())\n', 'n,k=map(int,input().split())\nif n==5 and k==3:\n exit()\nl=list(map(int,input().split()))\nif l.count(0)>0:\n k-=1\n if k==0:\n print(0)\n exit()\nelse:\n l.append(0)\n l.sort()\nl2=[]\nl3=[]\nfor i in range(len(l)-1):\n a=l[i+1]\n b=l[i]\n if a<=0:\n l2.append((a-b)*2)\n l3.append(a-b)\n else:\n l3.append((a-b)*2)\n l2.append(a-b)\nmi=100000000000000000000000000000\nx=l2[:k]\nfor i in range(k,len(l2)):\n x1=l2[i]\n if x[0]>=x1:\n for j in range(k-1):\n x[j]=x[j+1]\n mi_t=sum(x)\n if mi>mi_t:\n mi=mi_t\n else:\n for j in range(k-1):\n x[j]=x[j+1]\nx=l3[:k]\nfor i in range(k,len(l3)):\n x1=l3[i]\n if x[0]>=x1:\n for j in range(k-1):\n x[j]=x[j+1]\n mi_t=sum(x)\n if mi>mi_t:\n mi=mi_t\n else:\n for j in range(k-1):\n x[j]=x[j+1]\nprint(mi)', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n n,k=LI()\n l=LI()\n\n mn=inf\n for i in range(n-k+1):\n a=l[i]\n b=l[i+k-1]\n\n if a<0 and b>0:\n mn=min(mn,abs(a)+abs(b)*2,abs(a)*2+abs(b))\n else:\n mn=min(mn,max(abs(a),abs(b)))\n\n return mn\n\nprint(main())\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s359204815', 's729261715', 's692792721'] | [17192.0, 17636.0, 17136.0] | [104.0, 2104.0, 93.0] | [1103, 787, 515] |
p03274 | u952491523 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import sys\n\ndef ans(index, array, k):\n r = right(index, array, k)\n l = left(index, array, k)\n return min(r, l)\n\n\ndef right(index, array, k):\n start = min(index, k)\n count = sys.maxsize\n for i in range(start, min(len(array), k+index)):\n tmp = array[i]\n j = index - (k - (i - index + 1) + 1)\n tmp += array[i] - array[j]\n count = count if count < tmp else tmp\n\n if len(array) > (index + k - 1):\n count = count if count < array[index + k - 1] else array[index + k - 1]\n \n return count\n\ndef left(index, array, k):\n n = len(array)\n start = min(index, n - k + 1)\n count = sys.maxsize\n \n for i in range(max(0, start - k), start):\n tmp = -array[i]\n j = k + i - 1\n tmp += -array[i] + array[j]\n count = count if count < tmp else tmp\n\n if index >= k:\n count = count if count < -array[index-k] else -array[index-k]\n \n return count\n\nn,k = map(int, input().split())\n\nx = [int(i) for i in input().split()] \n\nindex = n\nfor i in range(n):\n if x[i] >= 0:\n index = i\n break\n\nprint(ans(index, x, k))', 'import sys\n\ndef ans(index, array, k):\n r = right(index, array, k)\n l = left(index, array, k)\n return min(r, l)\n\n\ndef right(index, array, k):\n start = max(0, k-(index-1)) + index\n count = sys.maxsize\n for i in range(start, min(len(array), k+index)):\n tmp = array[i]\n tmp += array[i] - array[k -(i - index + 1)]\n count = count if count < tmp else tmp\n\n if len(array) > (index + k - 1):\n count = count if count < array[index + k - 1] else array[index + k - 1]\n \n return count\n\ndef left(index, array, k):\n n = len(array)\n start = min(0, n-index-k) + index-1\n count = sys.maxsize\n \n for i in range(max(0, start - k), start):\n tmp = -array[i]\n tmp += -array[i] + array[k + i - 1]\n count = count if count < tmp else tmp\n\n if index >= k:\n count = count if count < -array[index-k] else -array[index-k]\n \n return count\n\nn,k = map(int, input().split())\n\nx = [int(i) for i in input().split()] \n\nindex = n\nfor i in range(n):\n if x[i] >= 0:\n index = i\n break\n\nprint(ans(index, x, k))', 'import sys\n\ndef ans(index, array, k):\n r = right(index, array, k)\n l = left(index, array, k)\n return min(r, l)\n\n\ndef right(index, array, k):\n start = max(0, k-index) + index\n count = sys.maxsize\n for i in range(start, min(len(array), k+index)):\n tmp = array[i]\n j = index - (k - (i - index + 1) + 1)\n tmp += array[i] - array[j]\n count = count if count < tmp else tmp\n\n if len(array) > (index + k - 1):\n count = count if count < array[index + k - 1] else array[index + k - 1]\n \n return count\n\ndef left(index, array, k):\n n = len(array)\n start = min(0, n-index-k) + index\n count = sys.maxsize\n \n for i in range(max(0, start - k), start+1):\n tmp = -array[i]\n j = k + i - 1\n tmp += -array[i] + array[j]\n count = count if count < tmp else tmp\n\n if index >= k:\n count = count if count < -array[index-k] else -array[index-k]\n \n return count\n\nn,k = map(int, input().split())\n\nx = [int(i) for i in input().split()] \n\nindex = n\nfor i in range(n):\n if x[i] >= 0:\n index = i\n break\n\nprint(ans(index, x, k))', 'import sys\n\ndef ans(index, array, k):\n r = right(index, array, k)\n l = left(index, array, k)\n return min(r, l)\n\n\ndef right(index, array, k):\n start = max(index, k-1)\n count = sys.maxsize\n for i in range(start, min(len(array), k+index)):\n tmp = array[i]\n j = index - (k - (i - index + 1))\n tmp += array[i] - array[j]\n count = count if count < tmp else tmp\n\n if len(array) > (index + k - 1):\n count = count if count < array[index + k - 1] else array[index + k - 1]\n \n return count\n\ndef left(index, array, k):\n n = len(array)\n start = min(index, n - k + 1)\n count = sys.maxsize\n \n for i in range(max(0, start - k), start):\n tmp = -array[i]\n j = k + i - 1\n tmp += -array[i] + array[j]\n count = count if count < tmp else tmp\n\n if index >= k:\n count = count if count < -array[index-k] else -array[index-k]\n \n return count\n\nn,k = map(int, input().split())\n\nx = [int(i) for i in input().split()] \n\nindex = n\nfor i in range(n):\n if x[i] >= 0:\n index = i\n break\n\nprint(ans(index, x, k))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s221357209', 's665857566', 's941025542', 's872693491'] | [14564.0, 14788.0, 14480.0, 14788.0] | [85.0, 76.0, 80.0, 81.0] | [1117, 1094, 1133, 1115] |
p03274 | u977193988 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\nX=[int(i) for i in input().split()]+[0]\nX.sort()\nsn=X.index(0)\nprint(X)\nroad=[]\nfor j in range(sn):\n if X[j+k]>0:\n road.append(abs(X[j]-0)+abs(X[j+k]-X[j]))\n else:\n road.append(abs(X[j]-0)+abs(X[j+k-1]-X[j]))\n\nfor j in range(sn+1,n-k+1):\n road.append(abs(X[j]-0)+abs(X[j+k-1]-X[j]))\n\nif len(road)>0:\n print(min(road))\nelse:\n print(0)', 'n,k=map(int,input().split())\nX=[int(i) for i in input().split()]\nroad=[]\nfor i in range(n-k+1):\n if X[i]<=0 and X[i+k-1]>=0:\n r=min(abs(X[i]),X[i+k-1])+X[i+k-1]-X[i]\n elif X[i]<=0 and X[i+k-1]<=0:\n r=abs(X[i])\n else:\n r=X[i+k-1]\n road.append(r)\n\nprint(min(road))\n'] | ['Runtime Error', 'Accepted'] | ['s450068269', 's664959889'] | [14568.0, 14252.0] | [90.0, 96.0] | [391, 296] |
p03274 | u987170100 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map(int, input().split())\nlst = [int(x) for x in input().split()]\nlst1 = [x for x in lst if x > 0]\nlst2 = list(reversed([x for x in lst if x < 0]))\n\nlen1 = len(lst1)\nlen2 = len(lst2)\nret = 100 ** 100\nfor x in range(K + 1):\n print(x)\n lst_a = lst1[:x]\n lst_b = lst2[: K - x]\n if len(lst_a) + len(lst_b) != K:\n continue\n\n if len(lst_a) == 0:\n ret = min(ret, abs(lst_b[-1]))\n elif len(lst_b) == 0:\n ret = min(ret, lst_a[-1])\n elif lst_a[-1] > abs(lst_b[-1]):\n tmp = abs(lst_b[-1]) * 2 + lst_a[-1]\n ret = min(ret, tmp)\n else:\n tmp = abs(lst_b[-1]) + lst_a[-1] * 2\n ret = min(ret, tmp)\n\nprint(ret)\n', 'N, K = map(int, input().split())\nlst = [int(x) for x in input().split()]\nret = 100 ** 100\nfor i in range(N - K + 1):\n if lst[i] >= 0 and lst[i + K - 1] >= 0:\n t = lst[i + K - 1]\n elif lst[i] < 0 and lst[i + K - 1] < 0:\n t = abs(lst[i])\n else:\n t = lst[i + K - 1] - lst[i] + min(abs(lst[i]), abs(lst[i + K - 1]))\n ret = min(ret, t)\nprint(ret)\n'] | ['Wrong Answer', 'Accepted'] | ['s870203790', 's319512927'] | [14480.0, 14224.0] | [2104.0, 102.0] | [673, 375] |
p03274 | u993622994 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = map(int, input().split())\nx = list(map(int, input().split()))\nans = 10**9 + 10\n\nfor i in range(n-k+1):\n left = i\n right = i+k\n to_right = abs(x[left]) + abs(x[right]-x[left])\n to_left = abs(x[right]) + abs(x[right]-x[left])\n if min(to_right, to_left) < ans:\n ans = min(to_right, to_left)\n\nprint(ans)', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\nans = 10**9 + 10\n\nfor i in range(n-k+1):\n left = i\n right = i+k-1\n to_right = abs(x[left]) + abs(x[right]-x[left])\n to_left = abs(x[right]) + abs(x[right]-x[left])\n if min(to_right, to_left) < ans:\n ans = min(to_right, to_left)\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s105160136', 's901960455'] | [14224.0, 14224.0] | [103.0, 102.0] | [328, 330] |
p03275 | u454481887 | 2,000 | 1,048,576 | We will define the **median** of a sequence b of length M, as follows: * Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the value of the (M / 2 + 1)-th element of b' is the median of b. Here, / is integer division, rounding down. For example, the median of (10, 30, 20) is 20; the median of (10, 30, 20, 40) is 30; the median of (10, 10, 10, 20, 30) is 10. Snuke comes up with the following problem. You are given a sequence a of length N. For each pair (l, r) (1 \leq l \leq r \leq N), let m_{l, r} be the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of a. We will list m_{l, r} for all pairs (l, r) to create a new sequence m. Find the median of m. | ['print(20)', 'print(10)', 'N = int(input())\na_list = list(map(int, input().split()))\ndef search(c):\n bar = N\n r = 0\n res_nega = 0\n dp_arr = [0]*(2*N+1)\n for i in range(N):\n dp_arr[bar] += 1\n if a_list[i] < c:\n r += dp_arr[bar]\n bar += 1\n else:\n r -= (dp_arr[bar-1])\n bar -= 1\n res_nega += r\n return res_nega\n# binary search\na_sorted = sorted(a_list)\nleft = 0\nright = N\nmid = N // 2\nC = N*(N+1) // 2\nwhile True:\n if search(a_sorted[mid]) <= C // 2:\n if mid == N-1:\n break\n elif search(a_sorted[mid+1]) > C // 2:\n break\n else:\n left = mid\n mid = (mid + right) // 2\n else:\n right = mid + 1\n mid = (mid + left) // 2\nprint(a_sorted[mid])\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s620465791', 's669607033', 's834976657'] | [2940.0, 2940.0, 14468.0] | [17.0, 22.0, 939.0] | [9, 9, 781] |
p03276 | u047668580 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | [' N,K = list(map(int,input().split()))\nxs = list(map(int,input().split()))\n\nans = 10 ** 10\nfor i,x in enumerate(xs):\n if N == 1:\n ans = abs(x)\n if i + K > N and i > 0:\n break\n num = abs(xs[ i + K - 1 ] - xs[i]) + abs(xs[i])\n num1 = abs(xs[ i + K - 1 ] - xs[i]) + abs(xs[i + K -1])\n ans = min([num,num1,ans])\nprint(ans)', 'N,K = list(map(int,input().split()))\nxs = list(map(int,input().split()))\n\nans = 10 ** 10\nfor i,x in enumerate(xs):\n if N == 1:\n ans = abs(x)\n if i + K > N and i > 0:\n break\n num = abs(xs[ i + K - 1 ] - xs[i]) + abs(xs[i])\n num1 = abs(xs[ i + K - 1 ] - xs[i]) + abs(xs[i + K -1])\n ans = min([num,num1,ans])\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s925673458', 's545862478'] | [2940.0, 14224.0] | [17.0, 112.0] | [350, 349] |
p03276 | u064408584 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int, input().split())\na=list(map(int, input().split()))\nb=sorted([-1*i for i in a])\nans=10**9\nfor i in range(n-k+1):\n if a[i]>=0:ans=min(ans,a[k-1])\n else:\n ans=min(ans,a[k+i-1]-a[i]*2)\nfor i in range(n-k+1):\n if b[i]>=0:ans=min(ans,a[k-1])\n else:\n ans=min(ans,b[k+i-1]-b[i]*2) \nprint(ans)', 'n,k=map(int, input().split())\na=list(map(int, input().split()))\na2=[i for i in a if i>=0]\nb=sorted([-1*i for i in a])\nb2=[i for i in b if i>=0]\nans=10**9\nfor i in range(n-k+1):\n if a[i]>=0:ans=min(ans,a2[k-1])\n else:\n ans=min(ans,a[k+i-1]-a[i]*2)\nfor i in range(n-k+1):\n if b[i]>=0:ans=min(ans,b2[k-1])\n else:\n ans=min(ans,b[k+i-1]-b[i]*2) \nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s446087609', 's300100997'] | [14252.0, 14844.0] | [100.0, 110.0] | [323, 377] |
p03276 | u201234972 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['from bisect import bisect\nN, K = map( int, input().split())\nX = list( map( int, input().split()))\nI = bisect(X, -1)\nXmin = X[:I]\nXmin = [ -x for x in Xmin[::-1]]\nXplu = X[I:]\nprint(Xmin)\nH = [10**9]*(10**5)\nXmin += H\nXplu += H\nans = 10**9\nfor i in range( min(I, K)):\n if i == K-1:\n ans = min(ans, Xmin[i])\n else:\n ans = min(ans, Xmin[i]*2 + Xplu[K-i-2])\nfor i in range( min(N-I, K)):\n if i == K-1:\n ans = min(ans, Xplu[i])\n else:\n ans = min(ans, Xplu[i]*2 + Xmin[K-i-2])\nprint(ans)', 'from bisect import bisect\nN, K = map( int, input().split())\nX = list( map( int, input().split()))\nI = bisect(X, -1)\nXmin = X[:I]\nXmin = [ -x for x in Xmin[::-1]]\nXplu = X[I:]\nH = [10**9]*(10**5)\nXmin += H\nXplu += H\nans = 10**9\nfor i in range( min(I, K)):\n if i == K-1:\n ans = min(ans, Xmin[i])\n else:\n ans = min(ans, Xmin[i]*2 + Xplu[K-i-2])\nfor i in range( min(N-I, K)):\n if i == K-1:\n ans = min(ans, Xplu[i])\n else:\n ans = min(ans, Xplu[i]*2 + Xmin[K-i-2])\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s857685872', 's389559591'] | [15504.0, 14480.0] | [122.0, 105.0] | [521, 509] |
p03276 | u218843509 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['from bisect import bisect_left\n\nn, k = map(int, input().split())\nx = list(map(int, input().split()))\npos = bisect_left(x, 0)\n\n\nif x[0] >= 0:\n\tprint(x[k - 1])\nelif x[-1] <= 0:\n\tprint(-x[-k])\nelse:\n\tans = float("inf")\n\tif pos + k <= n:\n\t\tans = x[pos + k - 1]\n\tif x[pos] == 0:\n\t\tif pos - k - 1 >= 0:\n\t\t\tans = min(ans, -x[pos - k - 1])\n\telse:\n\t\tif pos - k >= 0:\n\t\t\tans = min(ans, -x[pos - k])\n\tfor i in range(max(pos, k - 1 - pos), min(pos + k, n)):\n\t\t#print(i)\n\t\tright = x[i]\n\t\tleft = -x[pos - (k - (i - pos + 1))]\n\t\t\n\t\tans = min(ans, 2 * right + left, 2 * left + right)\n\n\tprint(ans)\n', 'from bisect import bisect_left\n\nn, k = map(int, input().split())\nx = list(map(int, input().split()))\npos = bisect_left(x, 0)\n\n\n\nif n == 1:\n\tprint(abs(x[0]))\nelif x[0] >= 0:\n\tprint(x[k - 1])\nelif x[-1] <= 0:\n\tprint(-x[-k])\nelse:\n\tans = float("inf")\n\tif pos + k <= n:\n\t\tans = x[pos + k - 1]\n\tif x[pos] == 0:\n\t\tif pos - k + 1 >= 0:\n\t\t\tans = min(ans, -x[pos - k + 1])\n\telse:\n\t\tif pos - k >= 0:\n\t\t\tans = min(ans, -x[pos - k])\n\tfor i in range(max(0, k - pos - 1), min(k - 1, n - pos)):\n\t\t#print(i)\n\t\tright = x[pos + i]\n\t\tleft = -x[pos - (k - i - 1)]\n\t\t\n\t\tans = min(ans, 2 * right + left, 2 * left + right)\n\n\tprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s289544228', 's513694038'] | [14548.0, 14388.0] | [92.0, 77.0] | [625, 657] |
p03276 | u237362582 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ["N, K = map(int, input().split(' '))\nx = list(map(int, input().split(' ')))\n\nx_min = []\nfor i in range(N):\n if x[i] == 0:\n K -= 1\n if x[i] > 0:\n break\n\nx_min = [0] + x[0:i][::-1]\nx_plus = [0] + x[i:]\nlength_m = len(x_min)\nlength_p = len(x_plus)\n\nans = 2*(x[0]) + x[-1]\n\nfor i in range(length_m):\n if (length_p-1) + i < K:\n continue\n if (i+1) > K:\n break\n temp = 2 * abs(x_min[i]) + abs(x_plus[K-i])\n# print(temp)\n ans = min(ans, temp)\n\nfor i in range(length_p):\n if (length_m-1) + i < K:\n continue\n if (i+1) > K:\n break\n temp = 2 * abs(x_plus[i]) + abs(x_min[K-1])\n# print(temp)\n ans = min(ans, temp)\n\nprint(ans)\n", "N, K = map(int, input().split(' '))\nx = list(map(int, input().split(' ')))\nans = abs(x[0]) + abs(x[0]-x[0+K-1])\n\nfor i in range(N-K+1):\n temp1 = abs(x[i]) + abs(x[i]-x[i+K-1])\n temp2 = abs(x[i+K-1]) + abs(x[i]-x[i+K-1])\n ans = min(ans, temp1, temp2)\n\nprint(ans)\n"] | ['Runtime Error', 'Accepted'] | ['s711733840', 's933307940'] | [14480.0, 14252.0] | [111.0, 97.0] | [716, 271] |
p03276 | u343454379 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=map(int,input().split())\nx=list(map(int,input().split()))\n\na=[]\nfor i in range(N-K+1):\n a.append(x[K-1+i]-x[i]+abs(x[i]))\nprint(min(a))\nprint(a)', 'N,K=map(int,input().split())\nx=list(map(int,input().split()))\n\na=[]\nfor i in range(N-K+1):\n a.append(x[K-1+i]-x[i]+min(abs(x[i]),abs(x[K-1+i])))\nprint(min(a))'] | ['Wrong Answer', 'Accepted'] | ['s563161365', 's855587657'] | [14388.0, 14392.0] | [69.0, 81.0] | [149, 159] |
p03276 | u397531548 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=map(int,input().split())\nX=list(map(int,input().split()))\nif X[0]>=0:\n b=X[K]\nelif X[-1]<=0:\n b=X[-K]\nelif 0 in X:\n a=0\n b=10**9\n for i in range(N):\n if X[i]==0:\n a=i\n break\n for j in range(max(0,K-1-a),min(K,N-a)):\n if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):\n b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))\nelse:\n a=0\n b=10**9\n for i in range(N):\n if X[i]>0:\n a=i\n break\n for j in range(max(-1,K-a-1),min(K,N-a)):\n if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):\n b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))\n print(X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])),j,X[a+j],X[a+j-K+1],min(K-a+1,N-a+1)) \nprint(b)', 'N,K=map(int,input().split())\nX=list(map(int,input().split()))\nif X[0]>=0:\n b=X[K-1]\nelif X[-1]<=0:\n b=abs(X[-K])\nelif 0 in X:\n a=0\n b=10**9\n for i in range(N):\n if X[i]==0:\n a=i\n break\n for j in range(max(0,K-1-a),min(K,N-a)):\n if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):\n b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))\nelse:\n a=0\n b=10**9\n for i in range(N):\n if X[i]>0:\n a=i\n break\n for j in range(max(-1,K-a-1),min(K,N-a)):\n if b>X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1])):\n b=X[a+j]-X[a+j-K+1]+min(abs(X[a+j]),abs(X[a+j-K+1]))\nprint(b)'] | ['Runtime Error', 'Accepted'] | ['s101954133', 's363590378'] | [14308.0, 14252.0] | [291.0, 91.0] | [789, 690] |
p03276 | u405483159 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N, K = map( int, input().split() )\nx = list( map( int, input().split() ))\n \nret = 10 ** 18\nfor i in range( N - K + 1 ):\n s = x[ i: K + i ]\n l, r = s[ 0 ], x[ - 1 ]\n ret = min( ret, abs( l - r ) + min( abs( r ), abs( l ) ) )\nprint( ret )', 'N, K = map( int, input().split() )\nx = list( map( int, input().split() ))\n \nret = 10 ** 18\nfor i in range( N - K + 1 ):\n l, r = x[i], x[ K + i - 1 ]\n ret = min( ret, abs( l - r ) + min( abs( r ), abs( l ) ) )\nprint( ret )'] | ['Wrong Answer', 'Accepted'] | ['s010880999', 's666871778'] | [14384.0, 14384.0] | [2104.0, 89.0] | [239, 223] |
p03276 | u452786862 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import statistics\n\ndef Medi(Arra, Haba):\n re = []\n for i_M in range(len(Arra) - Haba + 1):\n re.append(statistics.median_high(Arra[i_M: i_M+Haba]))\n return re\n\nN = int(input())\nA = list(map(int, input().split()))\nprint(A)\nans = []\n\nif N == 1:\n ans.append(A[0])\nelse:\n kuri = max(N//2, 10)\n for i in range(1, N+1):\n ans += Medi(A, i)\n so = ans\n so.sort()\n print(so)\n\n\nprint(statistics.median_high(ans))', '# S = input()\n# N = int(input())\nN, K = map(int, input().split())\nX = list(map(int, input().split()))\n# LR = [list(map(int, input().split())) for _ in range(M)]\n\nans = 10000000000\n\nif K == 1:\n for i in range(N):\n if ans > abs(X[i]):\n ans = abs(X[i])\nelse:\n for i in range(N - K+1):\n left = X[i]\n right = X[i + K - 1]\n sum = 0\n\n if abs(left) <= abs(right):\n sum += abs(left)\n else:\n sum += abs(right)\n\n sum += abs(left - right)\n\n if ans > sum:\n ans = sum\n\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s245600604', 's712303046'] | [5724.0, 14352.0] | [147.0, 81.0] | [453, 571] |
p03276 | u496009935 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['from scipy.special import comb\nimport itertools\n\nn, k = map(int, input().split())\nx = list(map(int, input().split()))\nX = []\nm = 3*10**8\n\nfor v in itertools.combinations(x, k):\n X.append(list(v))\n\nfor i in range(comb(n, k, exact=True)):\n m0 = min(X[i])\n m1 = max(X[i])\n a = min(abs(abs(m0)+abs(m1-m0), abs(m1)+abs(m1-m0)))\n if m > a:\n m = a\nprint(m)', 'n, k = map(int, input().split())\nx = list(map(int, input().split()))\nm = 3*10**8\n\nfor i in range(n-k+1):\n a = x[i]\n b = x[i+k-1]\n t= min(abs(a)+abs(b-a), abs(b)+abs(b-a))\n if m > t:\n m = t\nprint(m)'] | ['Runtime Error', 'Accepted'] | ['s247738404', 's538330464'] | [1281996.0, 20064.0] | [2236.0, 85.0] | [371, 216] |
p03276 | u619819312 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=[]\nif n==1:\n print(a[0])\nelse:\n for i in range(n-k+1):\n if a[i]<=0 and 0<=a[i+k-1]:\n s.append(min(2*a[i+k-1]-a[i],a[i+k-1]-2*a[i]))\n elif a[i+k]<=2:\n s.append(-a[i])\n else:\n s.append(a[i+k-1])\n print(min(s))', 'n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=[]\nif n==1:\n print(a[0])\nelse:\n for i in range(n-k+1):\n if a[i]<=0 and 0<=a[i+k-1]:\n s.append(min(2*a[i+k-1]-a[i],a[i+k-1]-2*a[i]))\n elif a[i+k-1]<=0:\n s.append(-a[i])\n else:\n s.append(a[i+k-1])\n print(min(s))'] | ['Runtime Error', 'Accepted'] | ['s647761781', 's266002936'] | [14252.0, 14844.0] | [91.0, 90.0] | [334, 336] |
p03276 | u637175065 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,k = LI()\n a = LI()\n bi = bisect.bisect_left(a, 0)\n r = inf\n if bi >= k:\n r = abs(a[bi-k])\n if bi+k-1 < n and r > a[bi+k-1]:\n r = a[bi+k-1]\n for i in range(n):\n if 0 > bi - i or bi + k - i - 1 >= n:\n continue\n t = -a[bi-i]\n u = a[bi+k-i-1]\n s = t + u + min(t,u)\n if r > s:\n r = s\n return r\n\n\n\nprint(main())\n', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\ndd = [(-1,0),(0,1),(1,0),(0,-1)]\nddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,k = LI()\n a = LI()\n bi = bisect.bisect_left(a, 0)\n r = inf\n if bi >= k:\n r = abs(a[bi-k])\n if bi+k-1 < n and r > a[bi+k-1]:\n r = a[bi+k-1]\n for i in range(1, n):\n if 0 > bi - i or bi + k - i - 1 >= n or bi + k - i - 1 < bi:\n continue\n t = -a[bi-i]\n u = a[bi+k-i-1]\n s = t + u + min(t,u)\n if r > s:\n r = s\n return r\n\n\n\nprint(main())\n'] | ['Wrong Answer', 'Accepted'] | ['s131057077', 's032689496'] | [16656.0, 16776.0] | [113.0, 112.0] | [1086, 1112] |
p03276 | u669696235 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['N,K=map(int,input().split())\nx=list(map(int,input().split()))\nans=10000000000000000000\nfor i in range(0,N-K+1):\n ls=(x[i])\n rs=(x[i+K-1])\n print(x[i],x[i+K-1])\n if(ls>0 and rs>0):\n ans=min(ans,rs)\n elif(ls<0 and rs<0):\n ans=min(ans,abs(ls))\n else:\n ans=min(abs(ls)+rs+min(abs(ls),rs),ans)\n\nprint(ans)', 'N,K=map(int,input().split())\nx=list(map(int,input().split()))\nans=10000000000000000000\nfor i in range(0,N-K+1):\n ls=(x[i])\n rs=(x[i+K-1])\n if(ls>0 and rs>0):\n ans=min(ans,rs)\n elif(ls<0 and rs<0):\n ans=min(ans,abs(ls))\n else:\n ans=min(abs(ls)+rs+min(abs(ls),rs),ans)\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s882392452', 's772349186'] | [14568.0, 14224.0] | [160.0, 97.0] | [339, 314] |
p03276 | u691896522 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n, k = list(map(int, input().split()))\nx = list(map(int, input().split()))\ni = 0\nmi = x[-1] - x[0] + min(abs(x[-1]),abs(x[0]))\nif n == 1:\n print("a")\n print(abs(x[0]))\n exit()\nwhile i <= n - k:\n print("{} {}".format(x[i + k - 1], x[i]))\n if mi >= ( x[i + k - 1] - x[i]) + min(abs(x[i + k - 1]),abs(x[i])):\n mi = (x[i + k - 1] - x[i]) + min(abs(x[i + k - 1]),abs(x[i]))\n i += 1\nprint(mi)', 'n, k = list(map(int, input().split()))\nx = list(map(int, input().split()))\ni = 0\nmi = x[-1] - x[0] + min(abs(x[-1]),abs(x[0]))\nif n == 1:\n print(abs(x[0]))\n exit()\nwhile i <= n - k:\n if mi >= ( x[i + k - 1] - x[i]) + min(abs(x[i + k - 1]),abs(x[i])):\n mi = (x[i + k - 1] - x[i]) + min(abs(x[i + k - 1]),abs(x[i]))\n i += 1\nprint(mi)'] | ['Wrong Answer', 'Accepted'] | ['s509616733', 's841761642'] | [14480.0, 14844.0] | [192.0, 122.0] | [412, 350] |
p03276 | u813102292 | 2,000 | 1,048,576 | There are N candles placed on a number line. The i-th candle from the left is placed on coordinate x_i. Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0. He can move left and right along the line with speed 1. He can also light a candle when he is at the same position as the candle, in negligible time. Find the minimum time required to light K candles. | ['n,k = (int(i) for i in input().split())\nx = list(int(i) for i in input().split())\nres = 0.0\nfor i in range(n-k):\n xl = x[i]\n xr = x[i+k]\n tmp = min(abs(xl)+abs(xr-xl), abs(xr)+abs(xr-xl))\n if type(res)==type(0.0):\n res = tmp\n else:\n res = min(res,tmp)\nprint(res)', 'n,k = (int(i) for i in input().split())\nx = list(int(i) for i in input().split())\nres = 1000000000\nfor i in range(n-k+1):\n xl = x[i]\n xr = x[i+k-1]\n tmp = min(abs(xl)+abs(xr-xl), abs(xr)+abs(xr-xl))\n res = min(res,tmp)\nprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s023704820', 's552516873'] | [14252.0, 14224.0] | [116.0, 103.0] | [291, 241] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.