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 |
|---|---|---|---|---|---|---|---|---|---|---|
p03137 | u504562455 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['#C-117\nn, m = [int(i) for i in input().split()]\nx = [int(i) for i in input().split()]\nif n >= m:\n print(0)\nelif n == 1:\n print(max(x) - min(x))\nelse:\n x.sort()\n x_diff = []\n for mi in range(m-1):\n x_diff.append(x[mi+1]-x[mi])\n print(x_diff)\n split_list = []\n for ni in range(n-1):\n split_idx = x_diff.index(max(x_diff))\n split_list.append(split_idx)\n x_diff[split_idx] = 0\n split_list.sort()\n print(split_list)\n print(x)\n ans = 0\n ans += x[split_list[0]] - x[0]\n print("ans",ans)\n for ni in range(n-2):\n l = split_list[ni]+1\n r = split_list[ni+1]\n ans += x[r] - x[l]\n print("ans",ans)\n ans += x[-1] - x[split_list[-1]+1]\n print(ans)\n', '#C-117\nn, m = [int(i) for i in input().split()]\nx = [int(i) for i in input().split()]\nif n >= m:\n print(0)\nelif n == 1:\n print(max(x) - min(x))\nelse:\n x.sort()\n x_diff = []\n for mi in range(m-1):\n x_diff.append([x[mi+1]-x[mi], mi])\n #print(x_diff)\n x_diff.sort(reverse = True)\n #print(x_diff)\n split_list = []\n for ni in range(n-1):\n split_idx = x_diff[ni][1]\n split_list.append(split_idx)\n split_list.sort()\n #print(split_list)\n #print(x)\n ans = 0\n ans += x[split_list[0]] - x[0]\n #print("ans",ans)\n for ni in range(n-2):\n l = split_list[ni]+1\n r = split_list[ni+1]\n ans += x[r] - x[l]\n #print("ans",ans)\n ans += x[-1] - x[split_list[-1]+1]\n print(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s479281106', 's739160235'] | [13960.0, 21324.0] | [2104.0, 222.0] | [674, 694] |
p03137 | u505349903 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import copy\n\nN, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N > M:\n ans = 0\nelse:\n ans = 0\n X.sort()\n diff = []\n for i in range(len(X) - 1):\n diff.append(X[i + 1] - X[i])\n print(diff)\n diff_orig = copy.copy(diff)\n diff.sort()\n index = []\n for i in range(N - 1):\n index.append(diff_orig.index(diff.pop()))\n index.append(-1)\n index.sort()\n i = len(index) - 1\n index.append(len(X) - 1)\n while i >= 0:\n ans += X[index[i + 1]] - X[index[i] + 1]\n i -= 1\nprint(ans)', 'import copy\n\nN, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N > M:\n ans = 0\nelse:\n ans = 0\n X.sort()\n diff = []\n for i in range(len(X) - 1):\n diff.append(X[i + 1] - X[i])\n diff_orig = copy.copy(diff)\n diff.sort()\n index = []\n for i in range(N - 1):\n index.append(diff_orig.index(diff.pop()))\n index.append(-1)\n index.sort()\n i = len(index) - 1\n index.append(len(X) - 1)\n while i >= 0:\n ans += X[index[i + 1]] - X[index[i] + 1]\n i -= 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s903315016', 's340336548'] | [14088.0, 14088.0] | [212.0, 210.0] | [557, 541] |
p03137 | u511899838 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int,input().split())\nlis = list(map(int, input().split()))\nlis.sort()\n\nif m <= n:\n print(0)\nelse:\n lis2 = [0]\n for i in range(m-1):\n lis2.append(int(abs(lis[i+1] - lis[i])))\n lis2.sort()\n lis2.reverse()\n del lis2[0:(m - n - 2)]\n print(sum(lis2))\n print(lis2)\n', 'n, m = map(int,input().split())\nlis = list(map(int, input().split()))\nlis.sort()\n\nif m <= n:\n print("0")\nelse:\n lis2 = [0]\n for i in range(m-1):\n lis2.append(int(abs(lis[i+1] - lis[i])))\n lis2.sort()\n lis2.reverse()\n del lis2[0:(m - n - 2)]\n print(sum(lis2))\n print(lis2)\n', 'n, m = map(int,input().split())\nlis = list(map(int, input().split()))\nlis.sort()\n\nif m <= n:\n print(0)\nelse:\n lis2 = [0]\n for i in range(m-1):\n lis2.append(int(abs(lis[i+1] - lis[i])))\n lis2.sort()\n lis2.reverse()\n del lis2[0:(n-1)]\n print(sum(lis2))\n\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s234025017', 's494327234', 's239840908'] | [13960.0, 13968.0, 13968.0] | [132.0, 139.0, 124.0] | [301, 303, 280] |
p03137 | u514118270 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nA = []\nfor i in range(M-1):\nA.sort()\nprint(sum(A[:M-N]))', 'N,M = map(int,input().split())\nX = list(map(int,input().split()))\nif N >= M:\n print(0)\n exit()\nX.sort()\nA = []\nfor i in range(M-1):\n A.append(X[i+1]-X[i])\nA.sort()\nprint(sum(A[:M-N]))'] | ['Runtime Error', 'Accepted'] | ['s601696997', 's102317171'] | [2940.0, 13968.0] | [17.0, 110.0] | [131, 192] |
p03137 | u518042385 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int,input().split())\nl=sorted(list(map(int,input().split())))\nl1=[]\nl2=0\nif n>=m:\n print(0)\nelse:\n for i in range(m-1):\n l1.append(l[i+1]-l[i])\n for i in range(m-n):\n l2+=l1[i]\n print(l2)\n\n \n', 'n,m=map(int,input().split())\nl=sorted(list(map(int,input().split())))\nl1=[]\nl2=0\nif n>=m:\n print(0)\nelse:\n for i in range(m-1):\n l1.append(l[i+1]-l[i])\n l1=sorted(l1)\n for i in range(m-n):\n l2+=l1[i]\n print(l2)\n\n \n'] | ['Wrong Answer', 'Accepted'] | ['s668376450', 's751235551'] | [13960.0, 13968.0] | [110.0, 117.0] | [210, 226] |
p03137 | u518556834 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\na = []\nans = 0\nfor i in range(m-1):\n a.append(x[i+1]-x[i])\nif n >= m:\n print(0)\nelse:\n for i in range(m-n+1):\n ans += a[i]\n print(ans)\n', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\na = []\nans = 0\nfor i in range(m-1):\n a.append(x[i+1]-x[i])\nif n >= m:\n print(0)\nelse:\n for i in range(n-1):\n ans += a[i]\n print(ans)', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\na = []\nans = 0\nfor i in range(m-1):\n a.append(x[i+1]-x[i])\nif n >= m:\n print(0)\nelse:\n for i in range(m-n):\n ans += a[i]\n print(ans)\n', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\na = []\nfor i in range(m-1):\n a.append(x[i+1]-x[i])\nif n >= m:\n print(0)\n else:\n for i in range(n-1):\n a.remove(max(a))\n print(sum(a))', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\na = []\nans = 0\nfor i in range(m-1):\n a.append(x[i+1]-x[i])\na.sort()\nif n >= m:\n print(0)\nelse:\n for i in range(n-1):\n ans += a[i]\n print(ans)\n', 'n,m = map(int,input().split())\nx = list(map(int,input().split())).sorted()\na = []\nfor i in range(m-1):\n a.append(x[i+1]-x[i])\nif n >= m:\n print(0)\n else:\n for i in range(n-1):\n a.remove(max(a))\n print(sum(a))\n\n ', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\na = []\nans = 0\nfor i in range(m-1):\n a.append(x[i+1]-x[i])\na.sort()\nif n >= m:\n print(0)\nelse:\n for i in range(m-n):\n ans += a[i]\n print(ans)\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s007894430', 's196932663', 's402022856', 's412703516', 's473980333', 's595892904', 's262171194'] | [13968.0, 13960.0, 13960.0, 2940.0, 13960.0, 2940.0, 13960.0] | [105.0, 113.0, 103.0, 18.0, 126.0, 17.0, 116.0] | [217, 214, 215, 222, 224, 226, 224] |
p03137 | u522937309 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import pandas as pd\n\nn,m =map(int, input().split()) \nx=list(map(int, input().split())) \n\nx.sort()\n\n\n\nif m == 1:\n print(0)\nelse:\n x_df = pd.Series(x)\n x_d_df = x_df.diff()\n x_d = x_d_df.values.tolist()\n x_d.pop(0)\n\n for i in range(n-1):\n x_d.remove(max(x_d))\n# print(x_d)\n \n sumd = sum(x_d) \n print(sumd)', 'n,m =map(int, input().split()) \nx=list(map(int, input().split())) \n\nx.sort()\nx_d = list()\n\nif m ==1:\n print(0)\nelse:\n for i in range(m-1):\n x_d.append(x[i+1] - x[i])\n\n print(x,x_d)\n\n for i in range(n-1):\n x_d.remove(max(x_d))\n sumd = sum(x_d) \n print(sumd)', 'import numpy as np\nn,m =map(int, input().split()) \nx=list(map(int, input().split())) \n\nx.sort()\nx_d = list()\n\nif n > m:\n print(0)\nelse:\n if m == 1:\n print(0)\n else:\n\n# x_d.append(x[i+1] - x[i]) \n x_d = list(np.diff(x))\n\n\n \n# x_d.remove(max(x_d))\n \n x_d.sort(reverse=True)\n# sumd = sum(x_d) \n sumd = sum(x_d[n-1:])\n print(sumd)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s574559808', 's915725499', 's203804846'] | [3064.0, 13960.0, 23024.0] | [18.0, 2104.0, 257.0] | [383, 326, 525] |
p03137 | u525227429 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['def game(n, m, x_list):\n if n >= m:\n return 0\n \n x_list.sort()\n interval = []\n for i in range(m - 1):\n interval.append(x_list[i + 1] - x_list[i])\n interval.sort(reverse = True)\n sum_interval = 0\n for i in range(n):\n sum_interval += interval[i]\n return abs(x_list[m - 1] - x_list[0]) - sum_interval\n\nn, m = map(int, input().split())\nx = list(map(int, input().split()))\n\nprint(game(n, m, x))', 'def game(n, m, x_list):\n if n >= m:\n return 0\n x_list.sort()\n count = 0\n stone = [x_list[0]]\n \n interval = []\n for i in range(m - 1):\n interval.append(x_list[i + 1] - x_list[i])\n interval.sort(reverse = True)\n if len(interval) > n - 1:\n del(interval[n - 1])\n tmp = 0\n for i in range(n - 1):\n for j in range(tmp, m - 1):\n if x_list[j + 1] - x_list[j] == interval[i]:\n stone.append(x_list[j + 1])\n tmp = j + 1\n break\n stone.sort()\n\n tmp = 1\n for i in range(n):\n for j in range(tmp, m):\n if i == n - 1:\n if x_list[j] == stone[n - 1]:\n count += abs(x_list[m - 1] - x_list[j])\n break\n elif x_list[j] == stone[i + 1]:\n count += abs(x_list[j - 1] - stone[i])\n tmp = j + 1\n break\n return count\n\nn, m = map(int, input().split())\nx = list(map(int, input().split()))\n\nprint(game(n, m, x))', 'def game(n, m, x_list):\n if n >= m:\n return 0\n \n x_list.sort()\n interval = []\n for i in range(m - 1):\n interval.append(abs(x_list[i + 1] - x_list[i]))\n interval.sort(reverse = True)\n sum_interval = 0\n for i in range(n - 1):\n sum_interval += interval[i]\n print(sum_interval)\n return abs(x_list[m - 1] - x_list[0]) - sum_interval\n\nn, m = map(int, input().split())\nx = list(map(int, input().split()))\n\nprint(game(n, m, x))', 'def game(n, m, x_list):\n if n >= m:\n return 0\n \n x_list.sort()\n interval = []\n for i in range(m - 1):\n interval.append(x_list[i + 1] - x_list[i])\n interval.sort(reverse = True)\n sum_interval = 0\n for i in range(n - 1):\n sum_interval += interval[i]\n return x_list[m - 1] - x_list[0] - sum_interval\n\nn, m = map(int, input().split())\nx = list(map(int, input().split()))\n\nprint(game(n, m, x))'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s451538145', 's695552906', 's863059384', 's032250013'] | [13960.0, 13968.0, 13968.0, 13968.0] | [109.0, 2104.0, 110.0, 107.0] | [407, 895, 438, 406] |
p03137 | u525595811 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\npoints = list(map(int, input().split()))\npoints = points[:m]\n\nif m <= n:\n print(0)\nelse:\n points.sort()\n dx = [ abs(points[i]-points[i+1]) for i in range(0,len(points)-1) ]\n dx.sort()\n print(sum(dx[:m-n]))\n print(dx[:m-n])', 'n, m = map(int, input().split())\npoints = list(map(int, input().split()))\npoints = points[:m]\n\nif m <= n:\n print(0)\nelse:\n points.sort()\n dx = [ abs(points[i]-points[i+1]) for i in range(0,len(points)-1) ]\n dx.sort()\n dx.reverse()\n print(sum(dx[n-1:]))\n'] | ['Wrong Answer', 'Accepted'] | ['s398658602', 's861768176'] | [13968.0, 13968.0] | [109.0, 106.0] | [273, 271] |
p03137 | u527261492 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import sys\nn,m=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\ndif=[]\nif m<=n:\n print(0)\n sys.exit()\nelse:\n for i in range(m-1):\n dif.append(x[i+1]-x[i]-1)\n dif.sort(reverse=True)\n ans=x[m-1]-x[0]\n for j in range(n-1):\n ans-=dif[j]\n print(ans)\n \n', 'import sys\nn,m=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\ndif=[]\nif m<=n:\n print(0)\n sys.exit()\nelse:\n for i in range(m-1):\n dif.append(x[i+1]-x[i]-1)\n dif.sort(reverse=True)\n ans=x[m-1]-x[0]+1\n for j in range(n-1):\n ans-=dif[j]\n print(ans-n+1)\n \n', 'import sys\nn,m=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\ndif=[]\nif m<=n:\n print(0)\n sys.exit()\nelse:\n for i in range(n-1):\n dif.append(x[i+1]-x[i]-1)\n dif.sort(reverse=True)\n ans=x[n-1]-x[0]+1\n for j in range(n):\n ans-=dif[j]\n print(ans-n+1)\n ', 'import sys\nn,m=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\ndif=[]\nif m<=n:\n print(0)\n sys.exit()\nelse:\n for i in range(m-1):\n dif.append(x[i+1]-x[i])\n dif.sort(reverse=True)\n ans=x[m-1]-x[0]\n for j in range(n-1):\n ans-=dif[j]\n print(ans)\n \n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s386951503', 's624412856', 's655945008', 's559931866'] | [13968.0, 13968.0, 13960.0, 13968.0] | [124.0, 125.0, 120.0, 127.0] | [279, 285, 282, 277] |
p03137 | u535423069 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import sys\n \nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip()\nnas = lambda: stdin.readline().split()\n\nn, m = na()\nx = na()\n\nd = [x[i] - x[i - 1] for i in range(1, m)]\n\nif n >= m:\n print(0)\nelse:\n print(sum(d[:m - n]))', 'import sys\n \nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip()\nnas = lambda: stdin.readline().split()\n\nn, m = na()\nx = na()\n\nx.sort()\nd = [x[i] - x[i - 1] for i in range(1, m)]\nd.sort()\nif n >= m:\n print(0)\nelse:\n print(sum(d[:m - n]))'] | ['Wrong Answer', 'Accepted'] | ['s850589345', 's230495566'] | [13956.0, 13316.0] | [58.0, 101.0] | [310, 327] |
p03137 | u537782349 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['a, b = map(int, input().split())\nif a >= b:\n print(0)\nelse:\n c = list(map(int, input().split()))\n c.sort()\n d = []\n for i in range(1, b):\n d.append([abs(c[i] - c[i-1]), i])\n d = sorted(d, key=lambda x: x[0], reverse=True)\n e = []\n for i in range(a-1):\n e.append(d[i])\n e.sort()\n f = []\n print(c)\n print(d)\n print(e)\n for i in range(len(e)):\n print(c[e[i][1]])\n f.append(c[e[i][1]])\n f.append(c[e[i][1]-1])\n\n f.append(c[0])\n f.append(c[len(c)-1])\n f.sort()\n print("-------------")\n g = 0\n for i in range(1, len(f), 2):\n g += f[i] - f[i-1]\n print(g)\n', 'a, b = map(int, input().split())\nif a >= b:\n print(0)\nelse:\n c = list(map(int, input().split()))\n c.sort()\n d = []\n for i in range(1, b):\n d.append([abs(c[i] - c[i-1]), i])\n d = sorted(d, key=lambda x: x[0], reverse=True)\n e = []\n for i in range(a-1):\n e.append(d[i])\n e.sort()\n f = []\n for i in range(len(e)):\n f.append(c[e[i][1]])\n f.append(c[e[i][1]-1])\n f.append(c[0])\n f.append(c[len(c)-1])\n f.sort()\n g = 0\n for i in range(1, len(f), 2):\n g += f[i] - f[i-1]\n print(g)\n'] | ['Wrong Answer', 'Accepted'] | ['s738267410', 's733844711'] | [26608.0, 22568.0] | [423.0, 256.0] | [653, 560] |
p03137 | u538381753 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ["n, m = [int(x) for x in input().split(' ')]\nx = sorted([int(x) for x in input().split(' ')])\n\nif n >= m:\n print(0)\n exit()\n\nprint(sorted([x[i] - x[i-1] for i in range(1, m)]))\ndiff = sum(sorted([abs(x[i] - x[i-1]) for i in range(1, m)])[:-n+1])\nprint(diff)\n", "n, m = [int(x) for x in input().split(' ')]\nx = sorted([int(x) for x in input().split(' ')])\n\nif n >= m:\n print(0)\n exit()\n\ndiff = sorted([abs(x[i] - x[i-1]) for i in range(1, m)])\nfor i in range(n-1):\n diff.pop()\n\nprint(sum(diff))\n"] | ['Wrong Answer', 'Accepted'] | ['s029358289', 's461809221'] | [13840.0, 13832.0] | [146.0, 116.0] | [263, 241] |
p03137 | u540761833 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M = list(map(int,input().split()))\nxarray = list(map(int,input().split()))\ndiff = []\nfor i in range(len(xarray)-1):\n diff.append(abs(xarray[i+1]-xarray[i]))\n\nif len(diff) == 0:\n print(0)\nelse:\n diff2 = sorted(diff, reverse = True)\n for j in range(N):\n diff2[j] = 0\n print(sum(diff2))', 'N,M = list(map(int,input().split()))\nxarray = list(map(int,input().split()))\ndiff = []\nif len(xarray) == 1:\n print(0)\nelse:\n for i in range(len(xarray)-1):\n diff.append(abs(xarray[i+1]-xarray[i]))\n if len(diff) == 0:\n print(0)\n else:\n diff2 = sorted(diff, reverse = True)\n for j in range(N):\n diff2[j] = 0\n print(sum(diff2))', 'N,M = list(map(int,input().split()))\nxarray = list(map(int,input().split()))\ndiff = []\nfor i in range(len(xarray)-1):\n diff.append(abs(xarray[i+1]-xarray[i]))\ndiff2 = sorted(diff, reverse = True)\nif len(diff2) == 0:\n print(0)\nelse:\n for j in range(N):\n diff2[j] = 0\n print(sum(diff2))', 'N,M = list(map(int,input().split()))\nxarray = list(map(int,input().split()))\nxarray.sort()\nprint(xarray)\ndiff = []\nif len(xarray) == 1:\n print(0)\nelse:\n for i in range(len(xarray)-1):\n diff.append(abs(xarray[i+1]-xarray[i]))\n if len(diff) == 0:\n print(0)\n else:\n diff2 = sorted(diff, reverse = True)\n print(diff)\n print(diff2)\n\n if N == 1:\n \n print(sum(diff2))\n else:\n for j in range(N-1):\n diff2[j] = 0\n print(sum(diff2))\n ', 'N,M = list(map(int,input().split()))\nxarray = list(map(int,input().split()))\ndiff = []\nfor i in range(len(xarray)-1):\n diff.append(abs(xarray[i+1]-xarray[i]))\ndiff2 = sorted(diff, reverse = True)\nfor j in range(N):\n diff2[j] = 0\nprint(sum(diff2))\n ', 'N,M = map(int,input().split())\nX = sorted(list(map(int,input().split())))\ndiff = []\nfor i in range(M-1):\n diff.append(X[i+1] - X[i])\ndiff.sort(reverse = True)\nif N >= M:\n print(0)\nelse:\n for i in range(N-1):\n diff.pop(0)\n print(sum(diff))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s121829476', 's236822121', 's278154401', 's508219615', 's767508849', 's950988237'] | [13968.0, 13960.0, 13968.0, 13960.0, 13968.0, 13968.0] | [115.0, 116.0, 116.0, 145.0, 114.0, 1539.0] | [307, 382, 303, 547, 257, 257] |
p03137 | u545411641 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N >= M:\n print(0)\n exit(0)\n\nL = [X[i+1] - X[i] for i in range(M-1)]\nL = sorted(L, reverse=True)\nL_sum = sum(L)\nans = L_sum\nfor i in range(N-1):\n ans -= L[i]\nprint(ans)', 'N, M = map(int, input().split())\nX = list(map(int, input().split()))\n \nif N >= M:\n print(0)\n exit(0)\n\nX = sorted(X)\nL = [X[i+1] - X[i] for i in range(M-1)]\nL = sorted(L, reverse=True)\nL_sum = sum(L)\nans = L_sum\nfor i in range(N-1):\n ans -= L[i]\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s968616400', 's016409565'] | [13960.0, 13960.0] | [115.0, 115.0] | [243, 258] |
p03137 | u552357043 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\nd = [0]*m\nfor i in range(1,m):\n d[i] = x[i]-x[i-1]\nd.sort()\nif n < m:\n d = d[1:m-n]\nelse:\n d = [0]\nans\nfor i in range(len(d)):\n ans += d[i]\nprint(ans)', 'n, m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\nd = [0]*m\nfor i in range(1,m):\n d[i] = x[i]-x[i-1]\nd.sort()\nif n < m:\n d = d[1:m-n+1]\nelse:\n d = [0]\nans = 0\nfor i in range(len(d)):\n ans += d[i]\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s208711616', 's975113719'] | [13960.0, 13960.0] | [114.0, 113.0] | [240, 246] |
p03137 | u554784585 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M=map(int,input().split())\nX=list(map(int,input().split()))\nY=[]\nX.sort()\nans=0\nif N>=M:\n print(0)\n exit()\nfor i in range(M-1):\n Y.append(X[i+1]-X[i])\nY.sort(reverse=True)\nfor j in range(N-1):\n ans+=Y[j]-1\nprint(ans)\n\nprint(X[M-1]-X[0]+1-ans-N)\n', 'N,M=map(int,input().split())\nX=list(map(int,input().split()))\nY=[]\nX.sort()\nans=0\nif N>=M:\n print(0)\n exit()\nfor i in range(M-1):\n Y.append(X[i+1]-X[i])\nY.sort(reverse=True)\nfor j in range(N-1):\n ans+=Y[j]-1\n\nprint(X[M-1]-X[0]+1-ans-N)\n'] | ['Wrong Answer', 'Accepted'] | ['s084872661', 's037299654'] | [20484.0, 20480.0] | [100.0, 106.0] | [259, 248] |
p03137 | u556487440 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import itertools\nn,m = map(int,input().split())\nzahyou_list = [i for i in map(int,input().split())]\nzahyou_list.sort()\n\nkaisa_list = []\n\n\nfor i in range(len(zahyou_list)-1):\n kaisa_list.append(zahyou_list[i+1] - zahyou_list[i])\nmini = sum(kaisa_list)\nkaisa_list.sort()\nprint(kaisa_list)\n\nif n >= m:\n print(0)\nelse:\n print(sum(kaisa_list[:-(n-1)]))\n', 'import itertools\nn,m = map(int,input().split())\nzahyou_list = [i for i in map(int,input().split())]\nzahyou_list.sort()\n\nkaisa_list = []\n\n\n\nfor i in range(len(zahyou_list)-1):\n kaisa_list.append(zahyou_list[i+1] - zahyou_list[i])\nmini = sum(kaisa_list)\nkaisa_list.sort()\n\nif n >= m:\n print(0)\nelif n == 1:\n print(sum(kaisa_list))\nelse:\n print(sum(kaisa_list[:-(n-1)]))\n'] | ['Wrong Answer', 'Accepted'] | ['s619323994', 's844271433'] | [13696.0, 13696.0] | [122.0, 124.0] | [399, 440] |
p03137 | u557437077 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['\ndef func(n, m, x):\n x.sort()\n dis = []\n for i in range(1, len(x)):\n dis.append(x[i] - x[i-1])\n dis.sort()\n n = min(n, m)\n # print("n:{} dis:{}".format(n, dis))\n print(sum(dis[:m-n]))\n\n # func(i, 7, [-10, -3, 0, 9, -100, 2, 17])\n"""\nfunc(3, 5, [1, 2, 10, 12, 14])\nfunc(3, 7, [-10, -3, 0, 9, -100, 2, 17])\nfunc(100, 1, [-100])\n"""\nn, m = [int(i) for i in input().split()]\nx = [int(i) for i in input().split()]\n', '\ndef func(n, m, x):\n x.sort()\n dis = []\n for i in range(1, len(x)):\n dis.append(x[i] - x[i-1])\n dis.sort()\n n = min(n, m)\n # print("n:{} dis:{}".format(n, dis))\n print(sum(dis[:m-n]))\n\n # func(i, 7, [-10, -3, 0, 9, -100, 2, 17])\n"""\nfunc(3, 5, [1, 2, 10, 12, 14])\nfunc(3, 7, [-10, -3, 0, 9, -100, 2, 17])\nfunc(100, 1, [-100])\n"""\nn, m = [int(i) for i in input().split()]\nx = [int(i) for i in input().split()]\nfunc(n, m, x)'] | ['Wrong Answer', 'Accepted'] | ['s820370299', 's296750088'] | [13832.0, 13872.0] | [49.0, 111.0] | [482, 495] |
p03137 | u557494880 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nans = X[-1] - X[0]\nd = []\nfor i in range(N-1):\n d.append(X[i+1]-X[i])\nd.sort()\nn = min(N-1,M-1)\nfor i in range(n):\n ans -= d[-i]\nprint(ans)', 'N,M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nans = X[-1] - X[0]\nd = []\nfor i in range(M-1):\n d.append(X[i+1]-X[i])\nd.sort()\nn = min(N-1,M-1)\nfor i in range(n):\n ans -= d[-i]\nprint(ans)\n', 'N,M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nd = []\nfor i in range(M-1):\n d.append(X[i+1]-X[i])\nd.sort()\nn = min(M-1,N-1)\nfor i in range(n):\n d.pop()\nans = sum(d)\nprint(ans)'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s064827989', 's713278077', 's372406925'] | [13968.0, 13960.0, 13968.0] | [140.0, 128.0, 122.0] | [220, 221, 209] |
p03137 | u557565572 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\ndis=[]\nans=0\nif n>m: ans=0\nelse:\n for i in range(len(x)-1):\n dis[i] = x[i+1] - x[i]\n\n y.reverse()\n\n for j in range(n-1):\n ans += y[j]\n\n return ans', 'n,m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\ndis=[]\nres=0\nif n>m: ans=0\nelse:\n for i in range(len(x)-1):\n dis[i] = x[i+1] - x[i]\n\n y.sort()\n\n for j in range(n-1):\n res += y[j]\n\n return sum(y) - res', 'n,m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\ndis=[]\nres=0\nif n>m: \n print(0)\nelse:\n for i in range(len(x)-1):\n dis[i] = x[i+1] - x[i]\n\n dis.sort()\n\n for j in range(n-1):\n res += y[j]\n\n print(sum(dis) - res)', 'n,m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\ndis=[]\nres=0\nif n>m: \n print(0)\nelse:\n for i in range(len(x)-1):\n dis[i] = x[i+1] - x[i]\n\n dis.sort()\n\n for j in range(n-1):\n res += dis[j]\n\n print(sum(dis) - res)', 'n,m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\ndis=[]\nif n>m: \n print(0)\nelse:\n for i in range(len(x)-1):\n dis[i] = x[i+1] - x[i]\n\n dis.sort()\n\n print(sum(dis[:m-n]))', 'n,m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\ndis=[]\nif n>m: \n print(0)\nelse:\n for i in range(m-1):\n dis[i] = x[i+1] - x[i]\n\n dis.sort() \n\n print(sum(dis[:m-n]))', 'n,m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\ndis=[x[i+1]-x[i] for i in range(m-1)]\ndis.sort()\nprint(sum(dis[:m-n]) if m>=n else 0)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s017189548', 's234426932', 's320547009', 's503505523', 's634369864', 's827360525', 's097969722'] | [3064.0, 3060.0, 13968.0, 13968.0, 13968.0, 13960.0, 13968.0] | [17.0, 18.0, 78.0, 76.0, 78.0, 78.0, 101.0] | [250, 256, 268, 270, 216, 212, 163] |
p03137 | u560867850 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\n\nX = sorted(map(int, input().split()))\n\ndistances = sorted((X[i+1]-X[i], i, i+1) for i in range(m-1))\n\nif n >= m:\n print(0)\n exit()\n\nans = 0\ndistances = distances[-n+1:]\ndistances.sort(key=lambda x: x[1])\n\nstart = 0\nfor _, l, r in distances:\n ans += X[l] - X[start]\n start = r\n\nif start < r:\n ans += X[-1] - X[start]\n\nprint(ans)', 'n, m = map(int, input().split())\n\n\nif n >= m:\n print(0)\n exit()\n\nX = sorted(map(int, input().split()))\n\ndistances = sorted(X[i+1]-X[i] for i in range(m-1))\nprint(distances)\nprint(sum(distances[:min(-n+1, -1)]))', 'n, m = map(int, input().split())\n\nX = sorted(map(int, input().split()))\n\ndistances = sorted((X[i+1]-X[i], i, i+1) for i in range(m-1))\n\nif n >= m:\n print(0)\n exit()\n\nans = 0\ndistances = distances[-n+1:]\ndistances.sort(key=lambda x: x[1])\n\nstart = 0\nfor _, l, r in distances:\n ans = X[l] - X[start]\n start = r\nprint(ans)', 'n, m = [int(c) for c in input().split()]\n\nx_s = sorted([int(c) for c in input().split()])\n\nn_s = []\nfor i in range(1, len(x_s)):\n n_s.append(abs(x_s[i-1] - x_s[i]))\n\nans = sorted(n_s)[:n-1]\nprint(sum(ans))', 'n, m = map(int, input().split())\n\n\nif n >= m:\n print(0)\n exit()\n\nX = sorted(map(int, input().split()))\n\ndistances = sorted((X[i+1]-X[i] for i in range(m-1)), reverse=True)\nprint(sum(distances[(n-1):]))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s001734174', 's357894771', 's681734581', 's968161625', 's732037579'] | [22092.0, 13960.0, 22104.0, 13832.0, 13968.0] | [197.0, 111.0, 190.0, 119.0, 108.0] | [376, 216, 331, 208, 207] |
p03137 | u561339958 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import sys\nn, m = map(int, input().split())\nX = list(map(int, input().split()))\nif n >= m:\n print(0)\n sys.exit()\nX.sort()\nprint(X)\nL = []\nfor i in range(m-1):\n L.append(X[i+1] - X[i])\n#print(L)\nL.sort(reverse=True)\n#print(L)\n#print(sum(L[0:1]))\nprint((X[m-1]-X[0]) - (sum(L[0:n-1])))', 'import sys\nn, m = map(int, input().split())\nX = list(map(int, input().split()))\nif n >= m:\n print(0)\n sys.exit()\nX.sort()\nL = []\nfor i in range(m-1):\n L.append(X[i+1] - X[i])\n#print(L)\nL.sort(reverse=True)\n#print(L)\n#print(sum(L[0:1]))\nprint((X[m-1]-X[0]) - (sum(L[0:n-1])))'] | ['Wrong Answer', 'Accepted'] | ['s958133201', 's203659609'] | [13960.0, 13960.0] | [122.0, 115.0] | [286, 277] |
p03137 | u565204025 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['# -*- coding: utf-8 -*-\n\nn, m = map(int,input().split())\nx = list(map(int,input().split()))\n\nx.sort()\n\nprint(x)\n\naida = [0] * (m-1)\nfor i in range(1,m):\n aida[i-1] = x[i] - x[i-1]\n\naida.sort()\naida.reverse()\n\ndel aida[:n-1]\n\nprint(sum(aida))\n', '# -*- coding: utf-8 -*-\n\n\n\nn, m = map(int,input().split())\nx = list(map(int,input().split()))\n\nx.sort()\n\naida = [0] * (m-1)\nfor i in range(1,m):\n aida[i-1] = x[i] - x[i-1]\n\naida.sort()\naida.reverse()\n\ndel aida[:n-1]\n\nprint(sum(aida))\n'] | ['Wrong Answer', 'Accepted'] | ['s638345699', 's654747926'] | [13968.0, 13968.0] | [127.0, 113.0] | [245, 296] |
p03137 | u567847331 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int,input().split())\na = list(map(int, input().split()))\na.sort()\n#print(a)\nif N>M:\n ans = 0\nelse\n distance = [abs(a[i+1] - a[i]) for i in range(M-1)]\n #print(distance)\n distance.sort()\n #print(distance)\n del distance[M-N:]\n ans = 0 \n for j in distance:\n ans += j\nprint(ans)', 'N, M = map(int,input().split())\na = list(map(int, input().split()))\na.sort()\n#print(a)\nif N > M:\n ans = 0\nelse:\n distance = [abs(a[i+1] - a[i]) for i in range(M-1)]\n #print(distance)\n distance.sort()\n #print(distance)\n del distance[M-N:]\n ans = 0 \n for j in distance:\n ans += j\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s069245008', 's854509978'] | [2940.0, 13968.0] | [18.0, 112.0] | [316, 319] |
p03137 | u578489732 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ["# -*- coding: utf-8 -*-\nimport sys\n# ----------------------------------------------------------------\n# Use Solve Function\n\ndef solve(lines):\n if N >= M:\n print(0)\n sys.exit(0)\n N,M = map(int, lines.pop(0).split(' '))\n X = list(map(int, lines.pop(0).split(' ')))\n X.sort()\n span = []\n for i in range(M-1):\n span.append( X[i+1] - X[i] )\n span.sort()\n for i in range(N-1):\n span.pop(-1)\n print(sum(span))\n\n#\n# main\n#\n\nlines = [x.strip() for x in sys.stdin.readlines()]\n\n#\n# solve !!\n#\nsolve(lines)\n", "# -*- coding: utf-8 -*-\nimport sys\n# ----------------------------------------------------------------\n# Use Solve Function\n\ndef solve(lines):\n N,M = map(int, lines.pop(0).split(' '))\n X = list(map(int, lines.pop(0).split(' ')))\n if N >= M:\n print(0)\n sys.exit(0)\n X.sort()\n span = []\n for i in range(M-1):\n span.append( X[i+1] - X[i] )\n span.sort()\n for i in range(N-1):\n span.pop(-1)\n print(sum(span))\n\n#\n# main\n#\n\nlines = [x.strip() for x in sys.stdin.readlines()]\n\n#\n# solve !!\n#\nsolve(lines)\n"] | ['Runtime Error', 'Accepted'] | ['s146848522', 's224921855'] | [4344.0, 13976.0] | [19.0, 116.0] | [551, 551] |
p03137 | u580093517 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M=map(int,input().split())\nX=sorted(set(list(map(int,input().split()))))\ns=[]\nfor i in range(M-1):\n s.append(X[i+1]-X[i])\ns=sorted(s)\nprint(sum(s[:M-N]))\nprint(s)', 'N,M=map(int,input().split())\nX=sorted(set(list(map(int,input().split()))))\ns=[]\nfor i in range(M-1):\n s.append(X[i+1]-X[i])\ns=sorted(s)\nprint(sum(s[:N]))', 'N,M = map(int,input().split())\nX = sorted(map(int,input().split()))\ns=[]\nfor i in range(M-1):\n s.append(X[i+1]-X[i])\ns = sorted(s)[::-1]\nprint(sum(s[N-1:]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s160833135', 's834243183', 's661782711'] | [14932.0, 14928.0, 13968.0] | [96.0, 88.0, 114.0] | [167, 156, 159] |
p03137 | u580362735 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import numpy as np\nN = int(input())\nA = list(map(int,input().split()))\nA = sorted(A)\nA_ = [2*i for i in A]\nA_ = [i%A[0] for i in A_]\nA_ = sorted(set(A_))\nif A_ == [0]*len(A_):\n print(A[0])\nelse:\n print(A_[1])', "import numpy as np\nN,M = map(int,input().split())\nX = list(map(int,input().split()))\n\nif N < M:\n X = sorted(X,reverse = True)\n X_ = abs(np.array(X[1:]) - np.array(X[:M-1]))\n X_ = sorted(X_,reverse = True)\n print(sum(X_[N-1:]))\nelse:\n print('0')"] | ['Runtime Error', 'Accepted'] | ['s275214526', 's067271110'] | [14436.0, 22984.0] | [149.0, 298.0] | [210, 249] |
p03137 | u580697892 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['#coding: utf-8\nN, M = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\ndiff = [abs(x[i] - x[i+1]) for i in range(M-1)]\ndiff.sort()\nprint(sum(diff[:M-N+1]) if N<=M else 0)', '#coding: utf-8\nN, M = map(int, input().split())\npoints = list(map(int, input().split()))\npoints.sort()\nkoma = [points[i+1] - points[i] for i in range(M-1)]\nsum_ = []\nfor i in range(M-N):\n koma.append(min(koma))\nprint(sum(sum_))\n', '#coding: utf-8\nN, M = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\ndiff = [abs(x[i] - x[i+1]) for i in range(M-1)]\ndiff.sort()\nans = 0\nprint(ans if N > M else ans + sum(diff[:M-N]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s425070554', 's688533184', 's536621882'] | [13968.0, 13968.0, 13960.0] | [109.0, 2104.0, 105.0] | [192, 229, 207] |
p03137 | u593019570 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['a = list(map(int,input().split()))\nb = list(map(int,input().split()))\nb.sort()\n\nc = []\nif len(b) != 1:\n for i in range(len(b) - 1):\n c.append(b[i+1] - b[i])\n\nif len(b) == 1:\n print(1)\n \n \nelse: \n for j in range(min(a[0] - 1,a[1]):\n for k in range(len(c)):\n if c[k] == max(c):\n c[k] = 0\n\n print(sum(c))\n', 'a = list(map(int,input().split()))\nb = list(map(int,input().split()))\nb.sort()\n\nc = []\nif len(b) != 0:\n for i in range(len(b) - 1):\n c.append(b[i+1] - b[i])\n\nif len(b) == 0:\n print(1)\n \n \nelse: \n for j in range(min(a[0] - 1,a[1]):\n for k in range(len(c)):\n if c[k] == max(c):\n c[k] = 0\n\n print(sum(c))', 'a = list(map(int,input().split()))\nb = list(map(int,input().split()))\nb.sort()\n\nc = []\nif len(b) != 1:\n for i in range(len(b) - 1):\n c.append(b[i+1] - b[i])\n\nif len(b) == 1:\n print(1)\n \n \nelse: \n for j in range(min(a[0] - 1,a[1])):\n for k in range(len(c)):\n if c[k] == max(c):\n c[k] = 0\n\n print(sum(c))\n', 'a,b = map(int,input().split())\n\nc = list(map(int,input().split()))\nc.sort()\n\nd = []\nfor i in range(b-1):\n d.append(c[i+1] - c[i])\n\nd.sort()\n\n#print(c,d)\n\nfor k in range(a - 1):\n if d == []:\n print(0)\n exit()\n d.pop()\n\nprint(sum(d))'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s351347948', 's828715645', 's984935447', 's005899133'] | [2940.0, 2940.0, 13960.0, 13968.0] | [18.0, 18.0, 2104.0, 126.0] | [329, 328, 330, 254] |
p03137 | u593567568 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\n\nD = [abs(X[i] - X[i+1]) for i in range(M-1)]\nD.sort(reverse=True)\n\nprint(sum(D[N+1:]))\n', 'N,M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\n\nD = [abs(X[i] - X[i+1]) for i in range(M-1)]\nD.sort(reverse=True)\n\nprint(sum(D[N:]))\n', 'N,M = map(int,input().split())\nX = list(map(int,input().split()))\n\nD = [abs(X[i] - X[i+1]) for i in range(N-1)]\nD.sort(reverse=True)\n\nprint(sum(D[M+1:]))', 'N,M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\n\nD = [abs(X[i] - X[i+1]) for i in range(M-1)]\nD.sort(reverse=True)\n\nprint(sum(D[N-1:]))\n'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s106978489', 's759097154', 's759490663', 's228494777'] | [13968.0, 13968.0, 13968.0, 13968.0] | [106.0, 102.0, 95.0, 107.0] | [163, 161, 153, 163] |
p03137 | u593590006 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int,input().split())\nl=[int(i) for i in input().split()]\nif n>=m:\n print(0)\n exit()\nl.sort() \ndiff=[l[i]-l[i-1] for i in range(1,n)]\ndiff.sort() \nfor i in range(n-1):\n diff.pop()\nprint(sum(diff))', 'n,m=map(int,input().split())\nl=[int(i) for i in input().split()]\nif n>=m:\n print(0)\n exit()\nl.sort() \ndiff=[l[i]-l[i-1] for i in range(1,n)]\ndiff.sort(reverse=1) \nfor i in range(n-1):\n diff.pop()\nprint(sum(diff))', 'n,m=map(int,input().split())\nl=[int(i) for i in input().split()]\nif n>=m:\n print(0)\n exit()\nl.sort() \ndiff=[l[i]-l[i-1] for i in range(1,m)]\ndiff.sort() \nfor i in range(n-1):\n diff.pop()\nprint(sum(diff))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s102472213', 's687921569', 's513481216'] | [13840.0, 13840.0, 13832.0] | [114.0, 110.0, 112.0] | [212, 221, 212] |
p03137 | u595289165 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\nl = [x[i]-x[i-1] for i in range(1,m)]\nans = x[m-1] - x[0] \nif len[x] == 1:\n print(ans)\nelse:\n for i in range(n-1):\n ans -= max(l)\n l.remove(max(l))\n print(ans)', 'n, m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\nl = [x[i]-x[i-1] for i in range(1,m)]\nl.sort(reverse=True)\nans = x[m-1] - x[0]\nif n >= m:\n print(0)\nelse:\n for i in range(n-1):\n ans -= l[i]\n print(ans)'] | ['Runtime Error', 'Accepted'] | ['s121270073', 's594595748'] | [13968.0, 13968.0] | [91.0, 112.0] | [260, 246] |
p03137 | u595786324 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m = map(int,input().split())\nl = sorted(list(map(int,input().split())))\nprint(l)\ndiff = sorted([l[i+1]-l[i] for i in range(0,m-1)],reverse = True)\nprint(diff)\nprint(l[-1]-l[0]-sum(diff[:n-1]))\n\n', 'n,m = map(int,input().split())\nl = sorted(list(map(int,input().split())))\ndiff = sorted([l[i+1]-l[i] for i in range(0,m-1)],reverse = True)\nprint(l[-1]-l[0]-sum(diff[:n-1]))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s182651776', 's982154351'] | [13964.0, 13960.0] | [122.0, 104.0] | [196, 175] |
p03137 | u597374218 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M=map(int,input().split())\nX=sorted(set(list(map(int,input().split()))))\nprint(X)\ns=[]\nfor i in range(M-1):s.append(X[i+1]-X[i])\ns=sorted(s)\nprint(sum(s[:N+1]))', 'N,M=map(int,input().split())\nX=sorted(map(int,input().split()))\ndiff=[0]*(M-1)\nfor i in range(M-1):\n diff[i]=X[i+1]-X[i]\nprint(sum(sorted(diff)[::-1][N-1:]))'] | ['Wrong Answer', 'Accepted'] | ['s164731415', 's553645191'] | [14972.0, 13960.0] | [105.0, 112.0] | [162, 160] |
p03137 | u600195339 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['Import sys\nn, m = map(int, input().split())\nx = list(map(int, input().split()))\na = []\n\nif m == 1:\n print(0)\n sys.exit()\n\n#x.sort()\nlist.sort(x)\n#print(x)\n\nfor i in range(1, m):\n a.append(x[i] - x[i-1])\n\nlist.sort(a, reverse=True)\n#print(a)\n\ncount = max(x) - min(x)\nfor i in range(n-1):\n if len(a) == 0:\n break\n count -= a[i]\n\nprint(count)\n', 'import sys\nn, m = map(int, input().split())\nx = list(map(int, input().split()))\na = []\n\nif m == 1:\n print(0)\n sys.exit()\n\n#x.sort()\nlist.sort(x)\n#print(x)\n\nfor i in range(1, m):\n a.append(x[i] - x[i-1])\n\nlist.sort(a, reverse=True)\n#print(a)\n\ncount = max(x) - min(x)\nfor i in range(n-1):\n if len(a) == 0:\n break\n a.pop()\n# count -= a[i]\n\n#print(count)\nprint(sum(a))\n', 'import sys\nn, m = map(int, input().split())\nx = list(map(int, input().split()))\na = []\n\nif m == 1:\n print(0)\n sys.exit()\n\n#x.sort()\nlist.sort(x)\n#print(x)\n\nfor i in range(1, m):\n a.append(x[i] - x[i-1])\n\n#list.sort(a, reverse=True)\na.sort()\n#print(a)\n\ncount = max(x) - min(x)\nfor i in range(n-1):\n if len(a) == 0:\n break\n a.pop()\n# count -= a[i]\n\n#print(count)\nprint(sum(a))'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s654900042', 's802436818', 's806906344'] | [2940.0, 13968.0, 13968.0] | [17.0, 139.0, 142.0] | [362, 390, 399] |
p03137 | u604341914 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = list(map(int ,input().split()))\nX = list(map(int, input().split()))\ndis = []\nif N >= M:\n print(str(0)+"\\n")\nelse:\n X.sort()\n for i in range(M-1):\n dis.append(abs(X[i+1] - X[i]))\n dis.sort()\n ans = sum(dis[:-(N-1)])\n print(str(ans)+"\\n")', 'N, M = list(map(int ,input().split()))\nX = list(map(int, input().split()))\ndis = []\nif N >= M:\n print(0)\nelse:\n X.sort()\n for i in range(M):\n dis.append(abs(X[i+1] - X[i]))\n dis.sort()\n print(dis)\n ans = sum(dis[:-(N-1)])\n print(ans)', 'N, M = list(map(int ,input().split()))\nX = list(map(int, input().split()))\ndis = []\nif N >= M:\n print(0)\nelse:\n X.sort()\n for i in range(M-1):\n dis.append(abs(X[i+1] - X[i]))\n dis.sort()\n print(dis)\n ans = sum(dis[:-(N-1)])\n print(ans)', 'N, M = list(map(int ,input().split()))\nX = list(map(int, input().split()))\ndis = []\nif N >= M:\n print(0)\nelse:\n X.sort()\n for i in range(M-1):\n dis.append(abs(X[i+1] - X[i]))\n dis.sort()\n print(dis)\n ans = sum(dis[:N+1])\n print(ans)', 'N, M = list(map(int ,input().split()))\nX = list(map(int, input().split()))\ndis = []\nif N >= M:\n print(0)\nelse:\n X.sort()\n for i in range(M-1):\n dis.append(abs(X[i+1] - X[i]))\n dis.sort(reverse=True)\n ans = max(X) - min(X) - sum(dis[:N-1])\n print(ans)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s185063586', 's305028075', 's692196503', 's807970002', 's069070412'] | [13968.0, 13968.0, 13968.0, 13968.0, 13968.0] | [115.0, 105.0, 123.0, 122.0, 124.0] | [268, 261, 263, 260, 275] |
p03137 | u607563136 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['x,m = map(int, input().split())\nx = sorted(list(map(int, input().split())))\n\nif n >= m:print(0)\nelse:\n dist = [abs(x[i+1] - x[i]) for i in range(m-1)]\n dist = sorted(dist)\n print(sum(dist[:-(n-1)]))', 'n,m = map(int, input().split())\nx = sorted(list(map(int, input().split())))\nprint(sum(sorted(abs([x[i+1]-x[i]) for i in range(m-1)])[:-(n-1)]))', 'x,m = map(int, input().split())\nx = sorted(list(map(int, input().split())))\n\nif n >= m:print(0)\nelse:\n dist = [abs(x[i+1] - x[i]) for i in range(M-1)]\n dist = sorted(dist)\n print(sum(dif[:-(n-1)]))', 'x,m = map(int, input().split())\nx = sorted(list(map(int, input().split())))\n\nif n >= m:print(0)\nelse:\n dist = [abs(x[i+1] - x[i]) for i in range(m-1)]\n dist = sorted(dist)\n print(sum(dif[:-(n-1)]))', 'n,m = map(int, input().split())\nx = sorted(list(map(int, input().split())))\n\nif n >= m:print(0)\nelse:\n dist = [abs(x[i+1] - x[i]) for i in range(m-1)]\n dist = sorted(dist)\n print(sum(dist[:m-n]))'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s101116380', 's102111770', 's115204857', 's612955385', 's051683352'] | [20508.0, 8976.0, 20640.0, 20320.0, 20572.0] | [64.0, 24.0, 62.0, 65.0, 89.0] | [207, 143, 206, 206, 204] |
p03137 | u612223903 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['if m<=n or i ==1:\n print(0)\nelse:\n n,m = map(int,input().split())\n x = list(map(int,input().split()))\n x_delta=[]\n x.sort()\n for i in range(len(x)-1):\n delta = x[i+1] - x[i]\n x_delta.append(delta)\n print(sum(sorted(x_delta)[:m-n]))', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nif m<=n :\n print(0)\nelse:\n x_delta=[]\n x.sort()\n for i in range(len(x)-1):\n delta = x[i+1] - x[i]\n x_delta.append(delta)\n print(sum(sorted(x_delta)[:m-n]))'] | ['Runtime Error', 'Accepted'] | ['s502806306', 's823366192'] | [3064.0, 13960.0] | [17.0, 116.0] | [266, 250] |
p03137 | u613128408 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import itertools\nN, M = list(map(int, input().split()))\nX = list(map(int, input().split()))\nX.sort()\n\nif N < M:\n mar = [X[i+1] - X[i] for i in range(len(M-1))]\n mar.sort()\n print(sum([mar[i] for i in range(M-N)]))\nelse:\n print(0)\n', 'import itertools\nN, M = list(map(int, input().split()))\nX = list(map(int, input().split()))\nX.sort()\n\nif N <= M:\n mar = [X[i+1] - X[i] for i in range(len(M-1))]\n mar.sort()\n print(sum([mar[i] for i in range(M-N)]))\nelse:\n print(0)\n', 'import itertools\nN, M = list(map(int, input().split()))\nX = list(map(int, input().split()))\nX.sort()\n\nif N < M:\n mar = [abs(X[i+1] - X[i]) for i in range(len(M-1))]\n mar.sort()\n print(sum([mar[i] for i in range(M-N)]))\nelse:\n print(0)\n', 'import itertools\nN, M = list(map(int, input().split()))\nX = list(map(int, input().split()))\nX.sort()\n\nif N < M:\n mar = [abs(X[i+1] - X[i]) for i in range(M-1)]\n mar.sort()\n print(sum([mar[i] for i in range(M-N)]))\nelse:\n print(0)\n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s481110795', 's533260309', 's569905728', 's362069881'] | [14336.0, 13696.0, 13696.0, 13696.0] | [80.0, 78.0, 79.0, 105.0] | [242, 243, 247, 242] |
p03137 | u619458041 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ["import sys\n\ndef split(g, n):\n gl = g[:-1]\n gr = g[1:]\n sub = [[(b - a), i] for a, b, i in zip(gl, gr, range(len(gl)))]\n i = sub.index(max(sub)) + 1\n sub = sorted(sub, key = lambda x: -x[0])\n j = []\n for i in range(n-1):\n j.append(sub[i][1]+1)\n j = sorted(j)\n jl = [0] + j[:-1]\n res = []\n for l, r in zip(jl, j):\n s = g[l:r]\n res.append(s)\n return res\n\n\ndef main():\n input = sys.stdin.readline\n N, M = map(int, input().split())\n g = [int(a) for a in input().split()]\n g = sorted(g)\n ans = 0\n if N < M:\n sp = split(g, N)\n for s in sp:\n ans += s[-1] - s[0]\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys\n\ndef split(g, n):\n gl = g[:-1]\n gr = g[1:]\n sub = [[(b - a), i+1] for a, b, i in zip(gl, gr, range(len(gl)))]\n sub = sorted(sub, key = lambda x: -x[0])\n j = []\n for i in range(n-1):\n j.append(sub[i][1])\n j = sorted(j)\n jl = [0] + j[:-1]\n res = []\n for l, r in zip(jl, j):\n s = g[l:r]\n res.append(s)\n R = j[-1]\n res.append(g[R:])\n print(res)\n return res\n\n\ndef main():\n input = sys.stdin.readline\n N, M = map(int, input().split())\n g = [int(a) for a in input().split()]\n g = sorted(g)\n ans = 0\n if N < M:\n sp = split(g, N)\n for s in sp:\n if len(s) <= 0:\n continue\n ans += s[-1] - s[0]\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys\n\ndef split(g, n):\n gl = g[:-1]\n gr = g[1:]\n sub = [[(b - a), i+1] for a, b, i in zip(gl, gr, range(len(gl)))]\n sub = sorted(sub, key = lambda x: -x[0])\n j = []\n for i in range(n-1):\n j.append(sub[i][1])\n j = sorted(j)\n jl = [0] + j[:-1]\n res = []\n for l, r in zip(jl, j):\n s = g[l:r]\n res.append(s)\n R = j[-1]\n if R < len(g):\n res.append(g[R:])\n print(res)\n return res\n\n\ndef main():\n input = sys.stdin.readline\n N, M = map(int, input().split())\n g = [int(a) for a in input().split()]\n g = sorted(g)\n ans = 0\n if N < M:\n sp = split(g, N)\n for s in sp:\n ans += s[-1] - s[0]\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "import sys\n\ndef main():\n input = sys.stdin.readline\n N, M = map(int, input().split())\n ans = 0\n if N < M:\n g = [int(a) for a in input().split()]\n g = sorted(g)\n L = g[:-1]\n R = g[1:]\n sub = [b - a for a, b in zip(L, R)]\n sub = sorted(sub)\n ans = sum(sub[:(M-N)])\n print(ans)\n\n\nif __name__ == '__main__':\n main()"] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s398479156', 's438429131', 's725905635', 's225023495'] | [34320.0, 34440.0, 34488.0, 13308.0] | [247.0, 266.0, 273.0, 101.0] | [642, 696, 676, 338] |
p03137 | u620806894 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m = map(int,input().split())\nlx = list(map(int,input().split()))\n\nlx.sort()\ndx = []\ns = 0\n\nfor i in range(len(lx)-1):\n dx.append(lx[i+1]-lx[i])\n\nif n == 1:\n print(lx[m-1]-lx[0])\nelif m <= n:\n print(0)\nelse:\n dx.sort()\n print(dx)\n for i in range(len(dx)-n+1):\n s = s + dx[i]\n print(s)', 'n,m = map(int,input().split())\nlx = list(map(int,input().split()))\n\nlx.sort()\ndx = []\ns = 0\n\nfor i in range(len(lx)-1):\n dx.append(lx[i+1]-lx[i])\n\nif n == 1:\n print(lx[m-1]-lx[0])\nelif m <= n:\n print(0)\nelse:\n dx.sort()\n for i in range(len(dx)-n+1):\n s = s + dx[i]\n print(s)'] | ['Wrong Answer', 'Accepted'] | ['s171010717', 's493655233'] | [13960.0, 13960.0] | [120.0, 115.0] | [295, 283] |
p03137 | u623687794 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int,input().split())\na=sorted(list(map(int,input().split())))\nb=[]\nfor i in range(m-1):\n b.append(a[i+1]-a[i])\nb.sort()\nif n>=m:\n print(0)\nelse:\n print(sum(b[m-n-1:]))', 'n,m=map(int,input().split())\na=sorted(list(map(int,input().split())))\nb=[]\nfor i in range(m-1):\n b.append(a[i+1]-a[i])\nb.sort(reverse=True)\nif n>=m:\n print(0)\nelse:\n print(sum(b[n-1:]))\n'] | ['Wrong Answer', 'Accepted'] | ['s285507966', 's910316345'] | [13968.0, 13960.0] | [113.0, 112.0] | [178, 189] |
p03137 | u624475441 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['\n\n#include <algorithm>\nusing namespace std;\n\nint main() {\n int N, M; cin >> N >> M;\n vector<int> X(M);\n for (auto& xi : X) cin >> xi;\n sort(X.begin(), X.end());\n vector<int> diff(M - 1);\n for (int i = 0; i < M - 1; i++) {\n diff[i] = abs(X[i] - X[i + 1]);\n }\n sort(diff.begin(), diff.end());\n int res = 0;\n for (int i = 0; i < (M - 1) - (N - 1); i++) {\n res += diff[i];\n }\n cout << res << endl;\n return 0;\n}', 'N, M = map(int, input().split())\nX = sorted(map(int, input().split()))\nD = sorted(abs(x - y) for x, y in zip(X, X[1:]))\nif N > 1:\n print(sum(D[:-(N-1)]))\nelse:\n print(sum(D))'] | ['Runtime Error', 'Accepted'] | ['s041661055', 's073410034'] | [2940.0, 13964.0] | [18.0, 103.0] | [495, 180] |
p03137 | u626337957 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N >= M:\n print(0)\nelse:\n X.sort()\n\n diffs = [0]*(M-1)\n\n for i in range(M-1):\n diffs[i] = abs(x[i+1] - X[i])\n\n diffs.sort(key= lambda x: -x[0])\n \n print(sum(diffs[N-1:]))\n \n \n \n\n \n \n', 'N, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N >= M:\n print(0)\nelse:\n X.sort()\n\n diffs = [0]*(M-1)\n\n for i in range(M-1):\n diffs[i] = abs(X[i+1] - X[i])\n\n diffs.sort(key= lambda x: -x)\n\n print(sum(diffs[N-1:]))'] | ['Runtime Error', 'Accepted'] | ['s438254440', 's050790186'] | [13960.0, 13968.0] | [77.0, 120.0] | [269, 247] |
p03137 | u633914031 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M=map(int,input().split())\nX=list(map(int,input().split()))\nX.sort()\ndistance=X[M-1]-X[0]\nsa=[]\nfor i in range(M-1):\n sa.append(X[i+1]-X[i])\nsa.sort()\nsum(sa[:(N-1)*(-1)])', 'N,M=map(int,input().split())\nX=list(map(int,input().split()))\nX.sort()\ndistance=X[M-1]-X[0]\nsa=[]\nfor i in range(M-1):\n sa.append(X[i+1]-X[i])\nsa.sort()\nif N > M:\n print(0)\nelse:\n print(sum(sa[:(N-1)]))', 'N,M=map(int,input().split())\nX=list(map(int,input().split()))\nX.sort()\nsa=[]\nfor i in range(M-1):\n sa.append(X[i+1]-X[i])\nsa.sort()\nif N > M:\n print(0)\nelse:\n print(sum(sa[:M-N]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s618884361', 's659366899', 's461254099'] | [13968.0, 13968.0, 13968.0] | [113.0, 115.0, 112.0] | [174, 205, 182] |
p03137 | u640919333 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import numpy as np\n\nN,M = map(int,input().split())\nXs = sorted([int(i) for i in input().split()])\n\nif N >= M:\n print(0)\nelif N == 1:\n print(Xs[-1]-Xs[0])\nelse:\n margin = [Xs[i+1]-Xs[i] for i in range(len(Xs)-1)]\n margin = [(i,x) for i,x in enumerate(margin)]\n point = [x[0] for x in sorted(margin,key=lambda x:x[1],reverse=True)[:N-1]]\n print(point)\n move = 0\n move += Xs[point[0]] - Xs[0]\n for i in range(1,len(point)):\n move += Xs[point[i]] - Xs[point[i-1]+1]\n move += Xs[-1] - Xs[point[-1]+1]\n print(move)\n', 'import numpy as np\n\nN,M = map(int,input().split())\nXs = sorted([int(i) for i in input().split()])\n\nif N >= M:\n print(0)\nelif N == 1:\n print(Xs[-1]-Xs[0])\nelse:\n margin = [Xs[i+1]-Xs[i] for i in range(len(Xs)-1)]\n margin = [(i,x) for i,x in enumerate(margin)]\n point = [x[0] for x in sorted(margin,key=lambda x:x[1],reverse=True)[:N-1]]\n move = 0\n move += Xs[point[0]] - Xs[0]\n for i in range(1,len(point)):\n move += Xs[point[i]] - Xs[point[i-1]+1]\n move += Xs[-1] - Xs[point[-1]+1]\n print(move)'] | ['Wrong Answer', 'Accepted'] | ['s614726816', 's527196819'] | [28788.0, 28204.0] | [310.0, 335.0] | [549, 531] |
p03137 | u642528832 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M = map(int,input().split())\nX = sorted(list(map(int,input().split())))\nB=[]\n\nif N>=M:\n print(0)\n exit()\nelse:\n for i in range(M-2):\n B.append(X[i+1]-X[i])\n\n B.sort()\n print(sum(B[:-(N-1)]))\n\n', 'N,M = map(int,input().split())\nX = sorted(list(map(int,input().split())))\nB=[]\n\nif N<=M:\n print(0)\n exit()\nelse:\n for i in range(M-1):\n B.append(X[i+1]-X[i])\n\n B.sort()\n print(sum(B[:M-N]))\n\n', 'N,M = map(int,input().split())\nX = sorted(list(map(int,input().split())))\n#X.sort()\nB=[]\n\nif N>=M:\n print(0)\nelse:\n for i in range(M-1):\n B.append(X[i+1]-X[i])\n\n B = sorted(B,reverse = True)\n print(sum(B[N-1:]))\n\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s164924598', 's942766043', 's104227756'] | [20348.0, 20536.0, 20436.0] | [94.0, 69.0, 88.0] | [216, 213, 232] |
p03137 | u644360640 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import heapq\nn,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\nx_range = []\ncut = [0]\ncount = 0\nfor i in range(m-1):\n x_range.append(abs(x[i]-x[i+1]))\nh = heapq.nlargest(n-1,x_range)\n\n\nfor i in h:\n cut.append(x_range.index(i)+1)\ncut.append(len(x))\n\n\nfor i in range(len(cut)-1):\n sum_range = x[cut[i]:cut[i+1]]\n print(1)\n count += abs(sum_range[0]-sum_range[len(sum_range)-1])\n#print(count)\n', 'import heapq\nn,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\nx_range = []\ncut = [0]\ncount = 0\nfor i in range(m-1):\n x_range.append(abs(x[i]-x[i+1]))\nh = heapq.nlargest(n-1,x_range)\n\n\nfor i in h:\n cut.append(x_range.index(i)+1)\ncut.append(len(x))\nprint(1)\n\n', 'import heapq\nn,m = map(int,input().split())\nx = list(map(int,input().split()))\nx.sort()\nx_range = []\ncut = [0]\ncount = 0\nfor i in range(m-1):\n x_range.append(abs(x[i]-x[i+1]))\nh = heapq.nlargest(n-1,x_range)\nprint(1)\n\n', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\ndist = []\nx.sort()\nif n > m:\n print(0)\nelse:\n for i in range(m-1):\n dist.append(x[i+1] -x[i])\n dist.sort()\n print(sum(dist[:m-n]))\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s053262916', 's653444990', 's733748827', 's461819561'] | [16760.0, 16720.0, 16720.0, 13968.0] | [221.0, 222.0, 173.0, 112.0] | [430, 431, 429, 216] |
p03137 | u649760109 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m = map(int,input().split())\nx = list(map(int, input().split()))\nx_new = sorted(x)\nintervals = [0]*(m-1)\nfor i in range(m-1):\n intervals[i] = x[i+1] - x[i]\nc = sorted(intervals, reverse=True)\ns = 0\nfor j in range(n-1):\n s += c[j]\n\nmin = sum(intervals) - s\nprint(s)\n ', 'n,m = map(int,input().split())\nx = list(map(int, input().split()))\nx_new = sorted(x)\nintervals = [0]*(m-1)\nfor i in range(m-1):\n intervals[i] = abs(x_new[i+1] - x_new[i])\nc = sorted(intervals, reverse=True)\ns = 0\nif n < m:\n for j in range(n-1):\n s += c[j]\n min = sum(intervals) - s\n print(min)\nelse:\n print(0)'] | ['Runtime Error', 'Accepted'] | ['s060743785', 's506672481'] | [13968.0, 13968.0] | [156.0, 126.0] | [271, 329] |
p03137 | u655975843 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['list1 = list(map(int, input().split()))\nN = list1[0]\nM = list1[1]\nlist2 = list(map(int, input().split()))\nlist2 = sorted(list2, reverse=True)\n# print(list2)\nlist3 = []\nfor i in range(len(list2) - 1):\n list3.append(list2[i] - list2[i + 1])\nlist3 = sorted(list3, reverse=True)\nprint(list3)\nsum = 0\nfor i in range(N - 1):\n sum = sum + list3.pop(0)\nans = list2[0] - list2[-1] - sum\nprint(ans)\n', 'list1 = list(map(int, input().split()))\nN = list1[0]\nM = list1[1]\nlist2 = list(map(int, input().split()))\nif list1[0] - list1[1] >= 0:\n print(0)\n exit(0)\nlist2 = sorted(list2, reverse=True)\n# print(list2)\nlist3 = []\nfor i in range(len(list2) - 1):\n list3.append(list2[i] - list2[i + 1])\nlist3 = sorted(list3, reverse=True)\n# print(list3)\nsum = 0\nfor i in range(N - 1):\n sum = sum + list3.pop(0)\nans = list2[0] - list2[-1] - sum\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s209149290', 's778975800'] | [13960.0, 13960.0] | [1623.0, 1557.0] | [395, 451] |
p03137 | u657994700 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\n\nX_dif = []\n\nexcep = 0\n\nif M == 1:\n excep = M1\n \nif not excep = M1:\n for i in range(M-1):\n X_dif.append(X[i+1]-X[i])\n \n X_dif.sort()\n X_dif.reverse()\n\n if len(X_dif) == 1:\n excep == X_dif1\n \n if not X_dif1:\n for N in range(N-1):\n X_dif.pop(0)\n\nif excep == M1:\n print(1)\nelif excep == X_dif1:\n print(2)\nelse:\n print(sum(X_dif))', "# print('input >>')\nN, M = map(int,(input().split()))\nX = list(map(int,(input().split())))\nX.sort()\nXdiff = [X[i + 1] - X[i] for i in range(len(X) - 1)]\nXdiff.sort()\nans = sum(Xdiff[:N+1])\nif N <= M:\n ans = 0\n\n# print('----------output----------')\nprint(ans)", "# print('input >>')\nN, M = map(int,(input().split()))\nX = list(map(int,(input().split())))\nX.sort()\nXdiff = [X[i + 1] - X[i] for i in range(len(X) - 1)]\nXdiff.sort(reverse=True)\nans = (X[-1]-X[0]) - sum(Xdiff[:N-1])\n\n# print('----------output----------')\nprint(ans)"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s065949855', 's858087005', 's070399285'] | [2940.0, 13968.0, 13960.0] | [18.0, 110.0, 101.0] | [470, 261, 265] |
p03137 | u665038048 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nX = list(map(int, input().split()))\nX.sort()\nif N >= M:\n print(0)\nelse:\n L = []\n for i in range(M-1):\n L.append(X[i+1] - X[i])\n L.sort()\n for i in range(N-1):\n del L[-1]\n print(sum(L[:-N+1]))', 'X = list(map(int, input().split()))\nX.sort()\nif N >= M:\n print(0)\nelse:\n L = []\n for i in range(M-1):\n L.append(X[i+1] - X[i])\n L.sort()\n for i in range(N-1):\n del L[-1]\n print(sum(L))', 'N, M = map(int, input().split())\nX = list(map(int, input().split()))\nX.sort()\nX_sub = []\nfor i in range(len(X)-1):\n X_sub.append(X[i+1]-X[i])\nX_sub.sort()\nfor i in range(N-1):\n del X_sub[-1]\nprint(X_sub)\nprint(sum(X_sub))', 'N, M = map(int, input().split())\nX = list(map(int, input().split()))\nif N >= M:\n print(0)\nelse:\n X.sort()\n X_sub = []\n for i in range(len(X)-1):\n X_sub.append(X[i+1]-X[i])\n X_sub.sort()\n for i in range(N-1):\n del X_sub[-1]\n print(sum(X_sub))'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s033905796', 's190433059', 's711980239', 's813793081'] | [13968.0, 3060.0, 13960.0, 13960.0] | [122.0, 17.0, 120.0, 119.0] | [256, 216, 227, 277] |
p03137 | u668503853 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M=map(int,input().split())\nX=sorted(list(map(int,input().split())))\nif N>=M:\n print(0)\n exit()\nelse:\n D=[]\n for i in range(M-1):\n D.append(X[i+1]-X[i])\n print(sum(sorted(D)[:M-N+1]))\n', 'N,M=map(int,input().split())\nX=sorted(list(map(int,input().split())))\nif N>=M:\n print(0)\n exit()\nelse:\n D=[0]*M\n for i in range(M-1):\n D[i]=X[i+1]-X[i]\n print(sum(sorted(D)[:M-N+1]))'] | ['Wrong Answer', 'Accepted'] | ['s502520243', 's152041179'] | [13968.0, 13968.0] | [113.0, 111.0] | [193, 190] |
p03137 | u676496404 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ["N,M = map(int,input().split())\nl = list(map(int,input().split()))\nif M <= N:\n print('0')\nelse:\n l.sort()\n li = []\n for i in range(M-1):\n difference = abs(l[i]-l[i+1])\n li.append(difference)\n li.sort().reverse()\n dif = 0\n for i in range(N-1):\n dif += li[i]\n print(l[M-1]-l[0]-dif)", "N,M = map(int,input().split())\nl = list(map(int,input().split()))\nif M <= N:\n print('0')\nelse:\n l.sort()\n li = []\n for i in range(M-1):\n difference = abs(l[i]-l[i+1])\n li.append(difference)\n li.sort()\n li.reverse()\n dif = 0\n for i in range(N-1):\n dif += li[i]\n print(l[M-1]-l[0]-dif)"] | ['Runtime Error', 'Accepted'] | ['s570438096', 's403742984'] | [13960.0, 13968.0] | [117.0, 134.0] | [325, 332] |
p03137 | u681110193 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['\nn,m=map(int,input().split())\nL=list(map(int,input().split()))\nL.sort()\nif m!=1:\n\n d=[[L[i+1]-L[i],i] for i in range(m-1)]\n d.sort()\n d.reverse()\n ans=L[m-1]-L[0]\n\n for i in range(n-1):\n a=d[i][1]\n print(a)\n d[a]=0\n ans-=(L[a+1]-L[a])\n print(ans)\n \n\nelse:\n print(0)\n\n\n\n', 'import numpy as np\nn,m=map(int,input().split())\nL=list(map(int,input().split()))\nL.sort()\n\nd=np.array([L[i+1]-L[i] for i in range(m-1)])\nans=L[m-1]-L[0]\n\nfor i in range(n-1):\n a=argmax(d)\n ans-(L[a+1]-L[a])\n d[a]=0\n \n\n\n\n\nprint(ans)\n', 'n,m=map(int,input().split())\nL=list(map(int,input().split()))\nL.sort()\nif n>=m:\n print(0)\nelif m!=1:\n\n d=[L[i+1]-L[i] for i in range(m-1)]\n d.sort()\n d.reverse()\n ans=L[-1]-L[0]\n\n\n ans-=sum(d[:n-1])\n print(ans)\n \n\nelse:\n print(0)\n\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s800643301', 's972118546', 's035730405'] | [20644.0, 23076.0, 13968.0] | [163.0, 247.0, 105.0] | [289, 236, 240] |
p03137 | u686036872 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nx = []\nfor i in range(M-1):\n x.append(abs(X[i+1]-X[i]))\n\nx.sort()\n\nprint(sum(x[:M-N]))', 'N, M = map(int, input().split())\nX = sorted(list(map(int, input().split())))\n\nx = []\nfor i in range(M-1):\n x.append(abs(X[i+1]-X[i]))\n\nx.sort(reverse=True)\nprint(sum(x[N-1:]))'] | ['Wrong Answer', 'Accepted'] | ['s161030927', 's722004328'] | [13968.0, 13968.0] | [106.0, 119.0] | [159, 178] |
p03137 | u688219499 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\ny=[]\nif n>=m:\n print(0)\n exit()\nfor i in range(m-1):\n y.append(x[i+1]-x[i])\nz=sorted(y,reverse=True)\ncount=0\nfor i in range(n-1):\n count+=z[i]\nprint(x)\nprint(z)\nprint(x[-1]-x[0]-count)', 'n,m=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\ny=[]\nif n>=m:\n print(0)\n exit()\nfor i in range(m-1):\n y.append(x[i+1]-x[i])\nz=sorted(y,reverse=True)\ncount=0\nfor i in range(n-1):\n count+=z[i]\nprint(x)\nprint(z)\nprint(x[-1]-x[0]-count)', 'n,m=map(int,input().split())\nx=list(map(int,input().split()))\nx.sort()\ny=[]\nif n>=m:\n print(0)\n exit()\nfor i in range(m-1):\n y.append(x[i+1]-x[i])\nz=sorted(y,reverse=True)\ncount=0\nfor i in range(n-1):\n count+=z[i]\nprint(x[-1]-x[0]-count)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s457607608', 's599767002', 's573812324'] | [13968.0, 13960.0, 13960.0] | [141.0, 141.0, 125.0] | [267, 267, 249] |
p03137 | u691018832 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\ncheak = [0]*m\nfor i in range(m):\n cheak[m] = abs[x[m+1]-x[m]]\ncheak.sort()\nfor j in range(n-1):\n cheak.pop(m-j)\nans = sum(cheak)\nprint(ans)', 'import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn, m, *x = map(int, read().split())\nx.sort(reverse=True)\nmemo = [0] * m\nfor i, (bf, af) in enumerate(zip(x, x[1:])):\n memo[i] = bf - af\nmemo.sort(reverse=True)\nprint(sum(memo[n - 1:]))\n'] | ['Runtime Error', 'Accepted'] | ['s466891298', 's128806117'] | [13968.0, 11696.0] | [78.0, 112.0] | [223, 336] |
p03137 | u694810977 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\nx = list(map(int, input().split()))\ncnt = 0\nif n > m:\n print(0)\n exit()\nx.sort()\nL = []\nprint(x)\nfor i in range(m - 1):\n print(i)\n L.append(x[i + 1] - x[i])\nL.sort()\nL.reverse()\nprint(L)\nfor i in range(n-1):\n L.pop(0)\nprint(sum(L))\n', 'n, m = map(int, input().split())\nx = list(map(int, input().split()))\ncnt = 0\nif n > m:\n print(0)\n exit()\nx.sort()\nL = []\nfor i in range(m - 1):\n L.append(x[i + 1] - x[i])\nL.sort()\nL.reverse()\nfor i in range(n-1):\n L.pop(0)\nprint(sum(L))\n'] | ['Wrong Answer', 'Accepted'] | ['s057065216', 's189254060'] | [13960.0, 13968.0] | [1674.0, 1610.0] | [280, 249] |
p03137 | u695429668 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\n\nX = list(map(int, input().split()))\n\nX.sort()\n\nbuff = []\n\nfor i in range(M-1):\n buff.append(abs(X[i+1]-X[i]))\n\n\nbuff.sort()\nbuff = buff[::-1]\n\nfor i in range(min(N-1, len(buff))):\n print(buff.pop(0))\n\nprint(sum(buff))', 'N, M = map(int, input().split())\n\nX = list(map(int, input().split()))\n\nX.sort()\n\nbuff = []\n\nfor i in range(M-1):\n buff.append(abs(X[i+1]-X[i]))\n\n\nbuff.sort()\nbuff = buff[::-1]\n\nfor i in range(min(N-1, len(buff))):\n print(buff.pop(0))\n\nprint(sum(buff))', 'N, M = map(int, input().split())\n\nX = list(map(int, input().split()))\n\nX.sort()\n\nbuff = []\n\nfor i in range(M-1):\n buff.append(abs(X[i+1]-X[i]))\n\n\nbuff.sort()\nbuff = buff[::-1]\n\nfor i in range(min(N-1, len(buff))):\n \n\nprint(sum(buff))', 'N, M = map(int, input().split())\n\nX = list(map(int, input().split()))\n\nX.sort()\n\nbuff = []\n\nfor i in range(M-1):\n buff.append(abs(X[i+1]-X[i]))\n\n\nbuff.sort()\nbuff = buff[::-1]\n\nfor i in range(min(N-1, len(buff))):\n buff.pop(0)\n\nprint(sum(buff))'] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s034756061', 's636949852', 's662043592', 's327596600'] | [13960.0, 13968.0, 2940.0, 13968.0] | [1691.0, 1685.0, 17.0, 1597.0] | [257, 257, 259, 250] |
p03137 | u698416089 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n = input().split()\nm=int(n[1])\nn=int(n[0])\nx = list(map(int, input().split()))\ngaplist=[]\nfor i in range(m-1):\n gaplist.append(x[i+1]-x[i])\ngaplist.sort()\ndel gaplist[(n-1)*-1:]\nprint(sum(gaplist))', 'n = input().split()\nm=int(n[1])\nn=int(n[0])\nx = list(map(int, input().split()))\nx.sort()\ngaplist=[]\nfor i in range(m-1):\n gaplist.append(x[i+1]-x[i])\ngaplist.sort()\nif n>1:\n del gaplist[(n-1)*-1:]\nprint(sum(gaplist))'] | ['Wrong Answer', 'Accepted'] | ['s104672228', 's930767988'] | [13960.0, 13968.0] | [104.0, 110.0] | [201, 222] |
p03137 | u700806147 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif M <= N:\n print(0)\nelse:\n X.sort()\n dX = np.diff(X)\n dX.sort()\n print(sum(dX[:N+1]))', 'import numpy as np\nN, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif M <= N:\n print(0)\nelse:\n X.sort()\n # print("X =", X)\n dX = np.diff(X)\n # print("dX =", dX)\n dX.sort()\n print(sum(dX[:M-N]))\n'] | ['Runtime Error', 'Accepted'] | ['s504491240', 's360169584'] | [13968.0, 22984.0] | [77.0, 363.0] | [171, 237] |
p03137 | u702582248 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int, input().split())\na=list(map(int, input().split()))\na.sort(reverse=True)\nprint(sum(a[m-1:]))\n', 'n,m=map(int, input().split())\na=list(map(int, input().split()))\na.sort(reversed=True)\nprint(sum(a[m-1:]))\n', 'n,m=map(int, input().split())\na=list(map(int, input().split()))\na.sort()\nb=[a[i+1]-a[i] for i in range(n-1)]\nb.sort(reverse=True)\nprint(sum(b[m-1:]))\n', 'n,m=map(int, input().split())\na=list(map(int, input().split()))\na.sort()\nb=[a[i+1]-a[i] for i in range(m-1)]\nb.sort(reverse=True)\nprint(sum(b[n-1:]))\n'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s601184338', 's824185734', 's861796840', 's483770955'] | [13968.0, 13968.0, 13968.0, 13968.0] | [82.0, 41.0, 100.0, 104.0] | [105, 106, 150, 150] |
p03137 | u703890795 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nX = list(map(int, input().split()))\nX = sorted(X)\nprint(X)\nY = [X[i+1]-X[i] for i in range(M-1)] \nY = sorted(Y)\nprint(Y)\nprint(sum(Y[:(M-N-1)]))', 'N, M = map(int, input().split())\nX = list(map(int, input().split()))\nX = sorted(X)\nY = [X[i+1]-X[i] for i in range(M-1)] \nY = sorted(Y)\nif N >= M:\n print(0)\nelse:\n print(sum(Y[:(M-N)]))'] | ['Wrong Answer', 'Accepted'] | ['s683714370', 's760423492'] | [13968.0, 13964.0] | [124.0, 101.0] | [193, 203] |
p03137 | u708255304 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split()) \n\nif N >= M:\n print(0)\nelse:\n A = sorted(list(map(int, input().split())))\n B = sorted(A[i]-A[i-1] for i in range(1, len(A)))\n print(sum[B[0:M-N]])\n', 'N, M = map(int, input().split()) \n\nif N >= M:\n print(0)\nelse:\n A = sorted(list(map(int, input().split())))\n B = sorted(A[i]-A[i-1] for i in range(1, len(A)))\n print(sum[B[:M-N]])\n', 'N, M = map(int, input().split()) \n\nif N >= M:\n print(0)\nelse:\n A = sorted(list(map(int, input().split())))\n B = sorted(A[i]-A[i-1] for i in range(1, len(A)))\n print(sum(B[0:M-N]))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s261521073', 's696678378', 's757024758'] | [13968.0, 13968.0, 13968.0] | [102.0, 106.0, 106.0] | [238, 237, 238] |
p03137 | u710063495 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['line1 = list(map(lambda x: int(x), input().split()))\nN = line1[0]\nM = line1[1]\nX = list(map(lambda x: int(x), input().split()))\n\nif N >= M or M == 1:\n print(0)\nelse:\n X.sort(key=lambda x:x, reverse=False)\n\n diff = []\n\n for i in range(0, M-1):\n diff.append(X[i + 1] - X[i])\n\n print(diff)\n\n for i in range(0, N-1):\n maxIndex = diff.index(max(diff))\n diff.pop(maxIndex)\n\n print(diff)\n print(sum(diff))\n', 'line1 = list(map(lambda x: int(x), input().split()))\nN = line1[0]\nM = line1[1]\nX = list(map(lambda x: int(x), input().split()))\n\nif N >= M or M == 1:\n print(0)\nelse:\n X.sort(key=lambda x:x, reverse=False)\n\n diff = list(map(lambda x: x[0]-x[1], zip(X[1:],X[:-1])))\n diff.sort(key=lambda s:s, reverse=False)\n\n if N == 1:\n print(sum(diff))\n else:\n print(sum(diff[:-(N-1)]))\n'] | ['Wrong Answer', 'Accepted'] | ['s426873393', 's286958997'] | [13960.0, 13960.0] | [2104.0, 139.0] | [416, 383] |
p03137 | u711245972 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int,input().split())\nif n>=m:\n print(0)\nelse:\n x=map(int,input().split())\n y=[int(i) for i in x]\n y.sort()\n z=[]\n for h in range(1,len(y)):\n z.append(y[h]-y[h-1])\n z.sort()\n print(z)\n w=z[:m-n]\n print(sum(w))\n', 'n,m=map(int,input().split())\nx=map(int,input().split())\nif n>=m:\n print(0)\nelse:\n y=[int(i) for i in x]\n y.sort()\n z=[]\n for h in range(1,len(y)):\n z.append(y[h]-y[h-1])\n z.sort()\n print(z)\n w=z[:m-n]\n print(sum(w))\n', 'n,m=map(int,input().split())\nx=map(int,input().split())\nif n>=m:\n print(0)\nelse:\n y=[int(i) for i in x]\n y.sort()\n z=[]\n for h in range(1,len(y)):\n z.append(y[h]-y[h-1])\n z.sort()\n w=z[:m-n]\n print(sum(w))\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s208556579', 's318152309', 's795086995'] | [13832.0, 13832.0, 13832.0] | [130.0, 129.0, 121.0] | [255, 251, 238] |
p03137 | u712975113 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M=map(int,input().split())\nX=sorted(list(map(int,input().split())))\nif N<M:\n print(X)\n D=sorted([X[i+1]-X[i] for i in range(M-1)])\n print(D)\n print(sum(D[i] for i in range(M-N)))\nelse:\n print(0)', 'N,M=map(int,input().split())\nX=sorted(list(map(int,input().split())))\nif N<M:\n D=sorted([X[i+1]-X[i] for i in range(M-1)])\n print(sum(D[i] for i in range(M-N)))\nelse:\n print(0)'] | ['Wrong Answer', 'Accepted'] | ['s993320343', 's509186386'] | [13960.0, 13960.0] | [125.0, 105.0] | [211, 185] |
p03137 | u720636500 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nlis = [int(x) for x in input().split()]\nlis.sort()\nif N >= M:\n print(0)\nelse:\n lis2 = []\n for i in range(M - 1):\n lis2.append(lis[i + 1] - lis[i])\n lis2.sort(reverse = True)\n k = 0\n for i in range(N - 1, M - 1)', 'N, M = map(int, input().split())\nlis = [int(x) for x in input().split()]\nlis.sort()\nif N >= M:\n print(0)\nelse:\n lis2 = []\n for i in range(M - 1):\n lis2.append(lis[i + 1] - lis[i])\n lis2.sort(reverse = True)\n k = 0\n for i in range(N - 1, M - 1):\n k += lis2[i]\n print(k) '] | ['Runtime Error', 'Accepted'] | ['s265728477', 's546493241'] | [3064.0, 13840.0] | [17.0, 120.0] | [252, 283] |
p03137 | u728120584 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nif N > M:\n print(0)\n exit()\nX = list(map(int, input().split()))\nX.sort()\nleng = []\nfor i in range(1, M):\n leng.append(X[i] - X[i-1])\nleng.sort()\nprint(sum(leng[:M-3]))', ' N, M = [int(n) for n in input().split()]\n X = sorted([int(n) for n in input().split()])\n if N>=M:\n print(0)\n else:\n dx = []\n for j in range(M-1):\n dx.append(X[j+1]-X[j])\n ans = sorted(dx, reverse=True)\n print(sum(ans[N-1:]))', 'N, M = map(int, input().split())\nX = list(map(int, input().split()))\nif N >= M:\n print(0)\n exit()\nX.sort()\nleng = []\nfor i in range(1, M):\n leng.append(X[i] - X[i-1])\nans = sorted(leng, reverse = True)\nprint(sum(ans[N - 1:]))'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s420104587', 's793892451', 's075198347'] | [13960.0, 2940.0, 13960.0] | [113.0, 17.0, 113.0] | [209, 283, 234] |
p03137 | u729133443 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m,*x=map(int,open(0).read().split());x.sort();print(sum(sorted(j-i for i,j in zip(x,x[1:]))[:n:-1]))', 'n,m,*x=map(int,open(0).read().split());x.sort();print(sum(sorted(j-i for i,j in zip(x,x[1:]))[-n::-1]))'] | ['Wrong Answer', 'Accepted'] | ['s547253357', 's822779558'] | [13964.0, 13964.0] | [98.0, 99.0] | [102, 103] |
p03137 | u730043482 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['fl = input()\nsl = input()\n\nkoma_num, pos_num = [int (x) for x in fl.split(" ")]\nposes = [int(x) for x in sl.split(" ")]\nposes.sort()\n\nif koma_num >= pos_num:\n print("0")\n exit()\n\ndists = []\ntotal = 0\nfor n in range(pos_num-1):\n dist = poses[n+1] - poses[n]\n dists.append(dist)\n total += dist\n\ndists.sort()\ndists.reverse()\nif(len(dists) == 0):\n print("0")\n exit()\n\nfor n in range(koma_num-1):\n print(n)\n total -= dists[n]\n\nprint(total)\n\n', 'fl = input()\nsl = input()\n\nkoma_num, pos_num = [int (x) for x in fl.split(" ")]\nposes = [int(x) for x in sl.split(" ")]\nposes.sort()\n\nif koma_num >= pos_num:\n print("0")\n exit()\n\ndists = []\ntotal = 0\nfor n in range(pos_num-1):\n dist = poses[n+1] - poses[n]\n dists.append(dist)\n total += dist\n\ndists.sort()\ndists.reverse()\n\nif(len(dists) == 0):\n print("0")\n exit()\n\nfor n in range(koma_num-1):\n total -= dists[n]\n\nprint(total)\n'] | ['Wrong Answer', 'Accepted'] | ['s542773823', 's087387281'] | [14468.0, 14468.0] | [193.0, 140.0] | [463, 450] |
p03137 | u731368968 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\n# if N >= M:\n# print()\nX = sorted(list(map(int, input().split())))\n\n\n\n\n\n\n\n\n\n\n\nprint(sum(sorted([X[i + 1] - X[i] for i in range(M - 1)])[: min(M - N, 0)]))\n', 'N, M = map(int, input().split())\n# if N >= M:\n# print()\nX = sorted(list(map(int, input().split())))\n\n\n\n\n\n\n\n\n\n\n\nprint(sum(sorted([X[i + 1] - X[i] for i in range(M - 1)])[: max(M - N, 0)]))\n'] | ['Wrong Answer', 'Accepted'] | ['s770505855', 's028706737'] | [13968.0, 13968.0] | [101.0, 104.0] | [777, 777] |
p03137 | u732468087 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['M, N = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N >= M:\n print(0)\nelse:\n distance = []\n X.sort()\n for i in range(M-1):\n distance = distance.append(X[i+1]-X[i])\n distance.sort(reverse=True)\n print(sum(distance[N:]))', 'N, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N >= M:\n print(0)\nelse:\n distance = []\n X.sort()\n for i in range(M-1):\n distance.append(X[i+1]-X[i])\n distance.sort(reverse=True)\n print(sum(distance[N-1:]))'] | ['Runtime Error', 'Accepted'] | ['s867039252', 's266303778'] | [13968.0, 13960.0] | [48.0, 110.0] | [264, 255] |
p03137 | u733608212 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\nli = list(map(int, input().split()))\n \nli.sort()\nmove_cost = [li[i+1] - li[i] for i in range(m-1)]\nmove_cost.sort()\nmove_cost = move_cost[:n-1]\n \nprint(sum(move_cost))', '\nn, m = map(int, input().split())\nli = list(map(int, input().split()))\n\nli.sort()\nmove_cost = [li[i+1] - li[i] for i in range(m-1)]\nmove_cost.sort()\nif n >= m:\n print(0)\nelse:\n print(move_cost[:-n+1])\n print(sum(move_cost[:-n+1]))', 'n, m = map(int, input().split())\nli = list(map(int, input().split()))\n \nli.sort()\nmove_cost = [li[i+1] - li[i] for i in range(m-1)]\nmove_cost.sort()\nif n > 1:\n move_cost = move_cost[:-n+1]\n\nprint(sum(move_cost))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s341214860', 's899877372', 's058069667'] | [13960.0, 13968.0, 13960.0] | [103.0, 106.0, 109.0] | [200, 239, 214] |
p03137 | u739456942 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\n\nif n < m:\n x_distance = [x[i + 1] - x[i] for i in range(m - 1)]\n x_distance.sort()\n print(x_distance)\n ans = 0\n for i in range (m - n):\n ans += x_distance[i]\n print(ans)\nelse:\n print(0)\n', 'n, m = map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\nif n >= m:\n print(0)\nelse:\n x_distance = [x2 - x1 for x1, x2 in zip(x, x[1:])]\n x_distance.sort()\n print(sum(x_distance[:m-n]))\n'] | ['Wrong Answer', 'Accepted'] | ['s824005520', 's432204233'] | [13968.0, 13968.0] | [120.0, 98.0] | [293, 218] |
p03137 | u741397536 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n, m = [int(i) for i in input().split()]\nx_arr = [int(i) for i in input().split()]\n\nx_sort = sorted(x_arr)\n\nif n >= m or m==1:\n print(0)\nelse:\n x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]\n x_sub = sorted(x_sub)\n print(sum(x_sub[:m-(n-1)]))\n', 'n, m = [int(i) for i in input().split()]\nx_arr = [int(i) for i in input().split()]\n\nx_sort = sorted(x_arr)\n\nif n >= m or m==1:\n print(0)\nelse:\n x_sub = [x_sort[i+1]-x_sort[i] for i in range(m-1)]\n x_sub = sorted(x_sub)\n print(sum(x_sub[:(m-1)-(n-1)]))\n'] | ['Wrong Answer', 'Accepted'] | ['s567627319', 's460466911'] | [13840.0, 13840.0] | [107.0, 105.0] | [260, 264] |
p03137 | u746206084 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['a,b = map(int,input().split())\nlis = list(map(int,input().split()))\nlis.sort()\nls=[]\nfor i in range(b-1):\n ls.append(lis[i+1]-lis[i])\nls.sort()\nprint(sum(ls[n-1:])\n ', 'a,b = map(int,input().split())\nlis = list(map(int,input().split()))\nlis.sort()\nls=[]\nfor i in range(b-1):\n ls.append(lis[i+1]-lis[i])\nls.sort(reverse=True)\nprint(sum(ls[a-1:]))'] | ['Runtime Error', 'Accepted'] | ['s317890512', 's556743347'] | [2940.0, 13968.0] | [17.0, 113.0] | [176, 179] |
p03137 | u746627216 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\n\nX = list(map(int, input().split())) \nX = sorted(X)\n\ndiff = []\nfor i in range(len(X)-1):\n diff.append(X[i+1] - X[i])\n\ndiff_sort = sorted(diff)\n\n\nif M == 1:\n print(0) \nelse:\n print(sum(diff_sort[0:N+1]))\nprint(diff_sort)', 'N, M = map(int, input().split())\n\nX = list(map(int, input().split())) \nX = sorted(X)\n\n\nif M <= N:\n print(0) \n \nelse:\n diff = []\n for i in range(len(X)-1):\n diff.append(X[i+1] - X[i])\n \n diff_sort = sorted(diff)\n \n print(sum(diff_sort[0:M-N]))\n'] | ['Wrong Answer', 'Accepted'] | ['s979470857', 's687903969'] | [13964.0, 13960.0] | [122.0, 113.0] | [264, 275] |
p03137 | u759412327 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M = map(int,input().split())\nX = sorted(map(int,input().split()))\nD = sorted(x2-x1 for x1,x2 in zip(X,X[1:]))\nprint(sum(D[:N-1]))', 'N,M = map(int,input().split())\nX = sorted(map(int,input().split()))\nD = sorted(x2-x1 for x1,x2 in zip(X,X[1:]))[::-1]\nprint(sum(D[N-1:]))'] | ['Wrong Answer', 'Accepted'] | ['s933279516', 's889026813'] | [20556.0, 20300.0] | [83.0, 78.0] | [131, 137] |
p03137 | u760771686 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int,input().split())\nX = list(map(int,input().split()))\nif len(X)<2:\n print(0)\nelse: \n X.sort()\n\n diffs = []\n for i in range(M-1):\n diffs.append(abs(X[i+1]-X[i]))\n diffs.sort(reverse=True)\n print(X[M-1]-X[0]-sum(diffs[:N]))', 'N, M = map(int,input().split())\nX = list(map(int,input().split()))\nif len(X)<2:\n print(0)\nelse: \n X.sort()\n\n diffs = []\n for i in range(M-1):\n diffs.append(abs(X[i+1]-X[i]))\n diffs.sort(reverse=True)\n print(X[M-1]-X[0]-sum(diffs[:N-1]))'] | ['Wrong Answer', 'Accepted'] | ['s002838311', 's973030247'] | [20380.0, 20516.0] | [94.0, 93.0] | [262, 264] |
p03137 | u762420987 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = map(int, input().split())\nXlist = sorted(list(map(int, input().split())), reverse=True)\nprint(sum(Xlist[:M - N]) if N < M else 0)\n', 'N, M = map(int, input().split())\nXlist = sorted(list(map(int, input().split())), reverse=True)\nLlist = []\nfor i in range(M - 1):\n Llist.append(Xlist[i + 1] - Xlist[i])\nprint(sum(Llist[:M - N]) if N < M else 0)\n', 'N, M = map(int, input().split())\nXlist = sorted(list(map(int, input().split())))[::-1]\nsbn = sorted([abs(Xlist[i] - Xlist[i+1]) for i in range(M-1)])[::-1]\nif N >= M:\n print(0)\nelse:\n print(sum(sbn[N-1:]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s415198514', 's711723195', 's955706715'] | [13968.0, 13968.0, 13960.0] | [77.0, 104.0, 108.0] | [137, 213, 211] |
p03137 | u762469320 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['M,N=map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nxdelta = []\n\nfor i in range(len(X)-1):\n\txdelta.append(abs(X[i+1]-X[i]))\n\nxdelta.sort()\n\n\nif M == 1:\n\tprint(0)\nelif N == 1:\n\tprint(sum(xdelta))\nelif M <= N:\n\tprint(0)\nelse:\n\tfor i in range(M-1):\n\t\txdelta.pop(-1)\n\tprint(sum(xdelta))', 'M,N=map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nxdelta = []\n\nfor i in range(len(X)-1):\n\txdelta.append(abs(X[i+1]-X[i]))\n\nxdelta.sort()\n\nif M > N:\n\tif N == 1:\n\t\tprint(sum(xdelta))\n\telse:\n\t\tfor i in range(M-1):\n\t\t\txdelta.pop(-1)\n\t\tprint(sum(xdelta))\nelse:\n\tprint(0)', 'M,N=map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nxdelta = []\n\nfor i in range(len(X)-1):\n\txdelta.append(abs(X[i+1]-X[i]))\n\nif xdelta == []:\n\tprint(int(sum(map(abs,X))))\nelse:\n\tfor i in range(M-1):\n\t\txdelta.pop(-1)\n\tprint(sum(xdelta))', 'N,M=map(int,input().split())\nX = list(map(int,input().split()))\nX.sort()\nxdelta = []\n\nfor i in range(len(X)-1):\n\txdelta.append(abs(X[i+1]-X[i]))\n\nxdelta.sort()\n\nif N < M:\n\tif N == 1:\n\t\tprint(sum(xdelta))\n\telse:\n\t\tfor i in range(N-1):\n\t\t\txdelta.pop(-1)\n\t\tprint(sum(xdelta))\nelse:\n\tprint(0)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s077170594', 's698175957', 's702604531', 's883173938'] | [13960.0, 13960.0, 13960.0, 13968.0] | [115.0, 115.0, 116.0, 124.0] | [317, 288, 256, 288] |
p03137 | u764956288 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ["N,M = list(map(int, input().split(' ')))\nXs = list(map(int, input().split(' ')))\n\nXs.sort()\nL=[]\nfor i in range(M-1):\n L.append(Xs[i+1]-Xs[i])\n \nL.sort()\nprint(sum(L[1-N]))", "N,M = list(map(int, input().split(' ')))\nXs = list(map(int, input().split(' ')))\n\nXs.sort()\nL=[]\nfor i in range(M-1):\n L.append(Xs[i+1]-Xs[i])\n \nL.sort()\nresult = sum(L[:1-N]) if N>1 else sum(L)\n\nprint(result)"] | ['Runtime Error', 'Accepted'] | ['s175061834', 's510679272'] | [13960.0, 13968.0] | [118.0, 116.0] | [174, 211] |
p03137 | u777922433 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import numpy as np\n\nN,M=[int(i) for i in input().split()]\nx=input().split()\ny=[int(i) for i in x]\ny.sort()\n\nif(N==1):\n print(y[M-1]-y[0])\n exit()\nif(M==1):\n print("0")\n exit()\n\ndiff=[]\nfor i in range(M-1):\n diff.append(y[i+1]-y[i])\nsub=[]\narray=np.array(diff)\nindex=np.argsort(array)\nc=index[-1::-1]\nfor i in range(N-1):\n sub.append(c[i])\nprint(sub)\nans=0\nfor i in range(N):\n if(i==0):\n ans+=y[sub[i]]-y[0]\n elif(i==N-1):\n ans+=y[M-1]-y[sub[i-1]+1]\n else:\n ans+=y[sub[i]]-y[sub[i-1]+1]\nprint(ans)', 'import numpy as np\n\nN,M=[int(i) for i in input().split()]\nx=input().split()\ny=[int(i) for i in x]\ny.sort()\nif(M==1):\n print("0")\n exit()\nif(N==1):\n print(y[M-1]-y[0])\n exit()\n\ndiff=[]\nfor i in range(M-1):\n diff.append(y[i+1]-y[i])\nsub=[]\narray=np.array(diff)\nindex=np.argsort(array)\nc=index[-1::-1]\nfor i in range(N-1):\n sub.append(c[i])\nprint(sub)\nans=0\nfor i in range(N):\n if(i==0):\n ans+=y[sub[i]]-y[0]\n elif(i==N-1):\n ans+=y[M-1]-y[sub[i-1]+1]\n else:\n ans+=y[sub[i]]-y[sub[i-1]+1]\nprint(ans)', 'import numpy as np\n \nN,M=[int(i) for i in input().split()]\nx=input().split()\ny=[int(i) for i in x]\ny.sort()\nif(N==1):\n print(max(y)-min(y))\n# print(y[M-1]-y[0])\n exit()\nif(M==1):\n print("0")\n exit()\nif(N>=M):\n print("0")\n exit()\ndiff=[]\nfor i in range(M-1):\n diff.append(y[i+1]-y[i])\nsub=[]\narray=np.array(diff)\nindex=np.argsort(array)\nc=index[-1::-1]\nfor i in range(N-1):\n sub.append(c[i])\nans=0\nfor i in range(N):\n if(i==0):\n ans+=y[sub[i]]-y[0]\n elif(i==N-1):\n ans+=y[M-1]-y[sub[i-1]+1]\n else:\n ans+=y[sub[i]]-y[sub[i-1]+1]\nprint(ans)\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s126442683', 's639871805', 's893259272'] | [30552.0, 30552.0, 28068.0] | [668.0, 623.0, 388.0] | [544, 543, 595] |
p03137 | u788068140 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['def calculate(n,m,arr):\n\n if n >= n:\n print(0)\n return\n\n arr.sort()\n drr = list([])\n for index in range(1,len(arr)):\n drr.append(arr[index] - arr[index-1])\n drr.sort()\n drr = drr[:(m-n)]\n print(sum(drr))\n\n\n\nS = input().split(" ")\nn = int(S[0])\nm = int(S[1])\n\nS = input().split(" ")\n\narr = list([int(s) for s in S])\n\n\ncalculate(n,m,arr)\n', 'def calculate(n,m,arr):\n\n if n >= m:\n print(0)\n return\n\n arr.sort()\n drr = list([])\n for index in range(1,len(arr)):\n drr.append(arr[index] - arr[index-1])\n drr.sort()\n drr = drr[:(m-1-n-1)]\n print(sum(drr))\n\n\n\nS = input().split(" ")\nn = int(S[0])\nm = int(S[1])\n\nS = input().split(" ")\n\narr = list([int(s) for s in S])\n\n\ncalculate(n,m,arr)\n', 'def calculate(n,m,arr):\n\n if n >= m:\n print(0)\n return\n\n arr.sort()\n drr = list([])\n for index in range(1,len(arr)):\n drr.append(arr[index] - arr[index-1])\n drr.sort()\n drr = drr[:(m-n)]\n print(sum(drr))\n\n\n\nS = input().split(" ")\nn = int(S[0])\nm = int(S[1])\n\nS = input().split(" ")\n\narr = list([int(s) for s in S])\n\n\ncalculate(n,m,arr)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s261448877', 's420971621', 's795141550'] | [14736.0, 14736.0, 14728.0] | [47.0, 116.0, 109.0] | [378, 382, 378] |
p03137 | u790865625 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['#!/usr/bin/env python3\nN, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N >= M:\n\tprint(0)\n\texit()\nX.sort()\ndis = [b - a for a, b in zip(X, X[1:])]\ndis.sort()\nprint(dis)\nprint(sum(dis[:M-N]))', '#!/usr/bin/env python3\nN, M = map(int, input().split())\nX = list(map(int, input().split()))\n\nif N >= M:\n\tprint(0)\n\texit()\nX.sort()\ndis = [b - a for a, b in zip(X, X[1:])]\ndis.sort()\n#print(dis)\nprint(sum(dis[:M-N]))'] | ['Wrong Answer', 'Accepted'] | ['s804158873', 's815132680'] | [13968.0, 13968.0] | [105.0, 96.0] | [214, 215] |
p03137 | u794910686 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['import numpy as np\n\nN,M= [int(i) for i in input().split()]\nX=sorted([int(i) for i in input().split()])\nwidth=abs(X[-1]-X[0])\nX=np.array(X)\n\nW=width//N\nm=X[0]\nM=X[-1]\nans=0\ncount=1\n\nif N>=M:\n print(0)\nelse:\n while M>=m+W*count:\n x=X[X<m+W*count]\n X=X[X>=m+W*count]\n count+=1\n try:\n ans+=abs(max(list(x))-min(list(x)))\n except:\n continue\n print(ans)\n', 'N,M=[int(i) for i in input().split()]\nX=sorted([int(i) for i in input().split()])\nL=sum(sorted(list(map(lambda x: x[1]-x[0], zip(X,X[1:]))))[:M-N])\nprint(0) if N>=M else print(L)'] | ['Wrong Answer', 'Accepted'] | ['s131161045', 's982248937'] | [23032.0, 13196.0] | [2108.0, 109.0] | [414, 178] |
p03137 | u799691369 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['a, b, c = map(int, input().split())\n\ncnt = 0\nwhile c > 0:\n c -= 1\n cnt += 1\n if b > 0:\n b -= 1\n cnt += 1\n continue\n elif a > 0:\n a -= 1\n continue\n else:\n break\n\nprint(cnt)\n\n', 'def func2(input_list):\n if n >= m:\n return 0\n\n input_list.sort()\n\n input_diff = []\n for i in range(m-1):\n diff = input_list[i+1] - input_list[i]\n input_diff.append(abs(diff))\n\n input_diff.sort(reverse=True)\n ans = input_list[-1] - input_list[0]\n for i in range(0, n-1):\n ans -= input_diff[i]\n\n return ans\n\nn, m = map(int, input().split())\ninput_list = [int(i) for i in input().split()]\n\nprint(func2(input_list))'] | ['Runtime Error', 'Accepted'] | ['s955388567', 's646064125'] | [3060.0, 13840.0] | [18.0, 115.0] | [230, 463] |
p03137 | u800780376 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['NM = input().split(" ")\nN = int(NM[0])\nM = int(NM[1])\n\nXin= input().split(" ")\n\n\nXls = []\ntousa = []\nfor i in range(0,M):\n Xls.append(int(Xin[i]))\n\nXls.sort()\n\nif M != 1:\n for i in range(0,M-1):\n tousa.append(abs(Xls[i+1] - Xls[i]))\n\n\n\n\ntousa.sort()\n\nif N>M:\n w = M-1\nelse:\n w = N\nfor i in range(0,w):\n tousa.pop()\n\nret = 0\n\nfor i in tousa:\n ret = i + ret\n\nprint(ret)\n', 'NM = input().split(" ")\nN = int(NM[0])\nM = int(NM[1])\n\nXin= input().split(" ")\n\n\nXls = []\ntousa = []\nfor i in range(0,M):\n Xls.append(int(Xin[i]))\n\nXls.sort()\n\nif M != 1:\n for i in range(0,M-1):\n tousa.append(abs(Xls[i+1] - Xls[i]))\n\n\n\n\ntousa.sort()\n\n\nif N<M:\n for i in range(0,N-1):\n tousa.pop()\nelse:\n print(0)\n exit()\nret = 0\n\nfor i in tousa:\n ret = i + ret\n\nprint(ret)\n'] | ['Runtime Error', 'Accepted'] | ['s941145703', 's428097968'] | [14472.0, 14472.0] | [149.0, 140.0] | [393, 405] |
p03137 | u803481017 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m = map(int,input().split())\nx = list(map(int,input().split()))\nif n >= m:\n print(0)\nelse:\n x.sort()\n y = []\n for i in range(len(x)-1):\n y.append(x[i+1]-x[i])\n y.sort()\n number = 0\n for i in range(len(y)-n+1):\n number = number + y[i]\n print(number)\n print(number)', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nif n >= m:\n print(0)\nelse:\n x.sort()\n y = []\n for i in range(len(x)-1):\n y.append(x[i+1]-x[i])\n y.sort()\n print(y)\n number = 0\n for i in range(len(y)-n+1):\n number = number + y[i]\n print(number)\n print(number)\n', 'n,m = map(int,input().split())\nx = list(map(int,input().split()))\nif n >= m:\n print(0)\nelse:\n x.sort()\n y = []\n for i in range(len(x)-1):\n y.append(x[i+1]-x[i])\n y.sort()\n number = 0\n for i in range(len(y)-n+1):\n number = number + y[i]\n print(number)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s228877561', 's901863954', 's889089138'] | [13968.0, 13960.0, 13960.0] | [171.0, 174.0, 116.0] | [310, 324, 288] |
p03137 | u809849468 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['NM = [int(i) for i in input().split()]\nX = [int(i) for i in input().split()]\nX.sort()\nif(NM[1] <= NM[0]):\n print(0)\nelif(NM[0] == 1):\n print(X[-1] - X[0])', 'NM = [int(i) for i in input().split()]\nX = [int(i) for i in input().split()]\nX.sort()\nif(NM[1] <= NM[0]):\n print(0)\nelse:\n list1 = []\n for i in range(NM[1] - 1):\n list1.append(X[i + 1] - X[i])\n list1.sort()\n while(NM[0] > 1):\n del list1[-1]\n NM[0] -= 1\n print(sum(list1))'] | ['Wrong Answer', 'Accepted'] | ['s513605322', 's195405929'] | [13832.0, 13832.0] | [81.0, 130.0] | [160, 308] |
p03137 | u815659544 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m = map(int, input().split())\narr = list(map(int, input().split()))\n\nif n >= m:\n print(0)\n\nelse:\n arr.sort()\n\n diff = [arr[i+1] - arr[i] for i in range(m-1)]\n diff.sort()\n\n print(sum(arr[0:m-n]))', 'n,m = map(int, input().split())\narr = list(map(int, input().split()))\n\nif n >= m:\n print(0)\n\nelse:\n arr.sort()\n\n diff = [arr[i+1] - arr[i] for i in range(m-1)]\n diff.sort()\n\n print(sum(diff[0:m-n]))'] | ['Wrong Answer', 'Accepted'] | ['s818836184', 's636021367'] | [13968.0, 13968.0] | [108.0, 103.0] | [212, 213] |
p03137 | u820052258 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int,input().split())\n\nx = list(map(int,input().split()))\n\nx.sort()\ny = x[1::]\ndlt = [i-j for (i,j) in zip(y,x)]\ndlt.sort()\nprint(dlt)\nif n==1:\n print(sum(dlt))\nelse:\n print(sum(dlt[0:-1*n+1]))\n', 'n,m=map(int,input().split())\n\nx = list(map(int,input().split()))\n\nx.sort()\ny = x[1::]\ndlt = [i-j for (i,j) in zip(y,x)]\ndlt.sort()\nif n==1:\n print(sum(dlt))\nelse:\n print(sum(dlt[0:-1*n+1]))\n\n'] | ['Wrong Answer', 'Accepted'] | ['s356898000', 's356515874'] | [13960.0, 13968.0] | [105.0, 96.0] | [203, 193] |
p03137 | u821432765 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N, M = [int(x) for x in input().split()]\nX = sorted([int(x) for x in input().split()])\n\ndiff = []\nfor i in range(M-1):\n diff.append(X[i+1]-X[i])\nprint(sum(sorted(diff)[:min(0,M-N)]))', 'n,m=map(int,input().split())\nx=sorted(list(map(int,input().split())))\nx=sorted([x[i+1]-x[i] for i in range(m-1)])\nprint(sum(x[1:]))\n', 'N, M = [int(x) for x in input().split()]\nX = sorted([int(x) for x in input().split()])\n\ndiff = []\nfor i in range(M-1):\n diff.append(X[i+1]-X[i])\nprint(sum(sorted(diff)[:max(0,M-N)]))'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s291320208', 's348805210', 's233754667'] | [13840.0, 13968.0, 13832.0] | [116.0, 100.0, 118.0] | [185, 132, 185] |
p03137 | u821712904 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n,m=map(int,input().split())\nx=[int(i) for i in input().split()]\nx.sort()\ny=[]\nif n-m>=0:\n print(0)\n exit(0)\nelse:\n for i in range(n-1):\n y.append(x[i+1]-x[i])\ny.sort()\nprint(sum(y[:n-m])\n \n \n \n\n', 'n,m=map(int,input().split())\nx=[input(i) for i in input().split()]\n\nx.sort()\ny=[]\nif n-m>=0:\n print(0)\n exit(0)\nelse:\n for i in range(m-1):\n y.append(x[i+1]-x[i])\ny.sort()\nprint(sum(y[:n-m+2]))', 'n,m=map(int,input().split())\nx=[int(i) for i in input().split()]\n\nx.sort()\ny=[]\nif n-m>=0:\n print(0)\n exit(0)\nelse:\n for i in range(m-1):\n y.append(x[i+1]-x[i])\ny.sort()\nprint(sum(y[:m-n]))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s514826761', 's896399165', 's150758712'] | [2940.0, 9980.0, 13840.0] | [17.0, 25.0, 115.0] | [204, 199, 196] |
p03137 | u829416877 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['N,M = map(int, input().split())\nX = list(map(int,input().split()))\nif N >= M:\n print(0)\nelse:\n X = sorted(X)\n list = [0]*(M-1)\n for i in range(M-1):\n list[i] += X[i+1]-X[i]\n list = sorted(list)\n list1 = list[:M-N]\n print(sum(list1))', 'N,M = map(int, input().split())\nX = list(map(int,input().split()))\nif N >= M:\n print(0)\nelse:\n X = sorted(X)\n list = [X[i]-X[i-1] for i in range(1,M)]\n list = sorted(list)\n list1 = list[:M-N]\n print(sum(list1))'] | ['Wrong Answer', 'Accepted'] | ['s301460375', 's742159773'] | [20500.0, 20172.0] | [2206.0, 88.0] | [246, 216] |
p03137 | u840988663 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['n = list(map(int, input().split())) \ni = list(map(int, input().split())) \ni.sort()\nif(n[0] >= n[1]):\n print(0)\n break\nelse:\n\tk=1\n\tkyori=list()\n\twhile k < n[1]: \n\t sa=i[k]-i[k-1]\n\t kyori.append(sa)\n\t k=k+1\n\tkyori.sort()\n\tmm=1\n\towari=n[1]-n[0]\n\tkyori=kyori[0:owari]\n\tidou=sum(kyori)\n\tprint(idou)', 'n = list(map(int, input().split())) \ni = list(map(int, input().split())) \ni.sort()\nif(n[0] >= n[1]):\n print(0)\nelse:\n\tk=1\n\tkyori=list()\n\twhile k < n[1]: \n\t sa=i[k]-i[k-1]\n\t kyori.append(sa)\n\t k=k+1\n\tkyori.sort()\n\tmm=1\n\towari=n[1]-n[0]\n\tkyori=kyori[0:owari]\n\tidou=sum(kyori)\n\tprint(idou)'] | ['Runtime Error', 'Accepted'] | ['s665158980', 's945274191'] | [3064.0, 13968.0] | [17.0, 120.0] | [298, 290] |
p03137 | u852038767 | 2,000 | 1,048,576 | We will play a one-player game using a number line and N pieces. First, we place each of these pieces at some integer coordinate. Here, multiple pieces can be placed at the same coordinate. Our objective is to visit all of the M coordinates X_1, X_2, ..., X_M with these pieces, by repeating the following move: **Move** : Choose a piece and let x be its coordinate. Put that piece at coordinate x+1 or x-1. Note that the coordinates where we initially place the pieces are already regarded as visited. Find the minimum number of moves required to achieve the objective. | ['nm = list(map(int, input().split()))\nlis = list(map(int, input().split()))\n\nlis.sort()\n\nsum = 0\ndiff = []\n\nif nm[1] - nm[0] <= 0:\n print(0)\nelse:\n for i in range (nm[1] - 1):\n diff[i] = lis[i + 1] - lis[i]\n\n diff.sort()\n\n for j in range (nm[0] - 1):\n diff.pop(-1)\n\n for k in range (nm[1] - nm [0] - 1):\n sum = sum + diff[k]\n \n print(sum)', 'nm = list(map(int, input().split()))\nlis = list(map(int, input().split()))\n\nlis.sort()\n\nsum = 0\ndiff = []\n\nif nm[1] - nm[0] <= 0:\n print(0)\nelse:\n for i in range (nm[1] - 1):\n diff.append(lis[i + 1] - lis[i])\n\n diff.sort()\n print(diff)\n\n if nm[0] != 1:\n for j in range (nm[0] - 2):\n diff.pop(-1)\n\n for k in range (nm[1] - nm [0]):\n sum = sum + diff[k]\n\n print(sum)\n', 'import numpy as np\n\nnm = list(map(int, input().split()))\nlis = list(map(int, input().split()))\n\nlis.sort()\n\ndiff = []\n\nfor i in range (nm[1] - 1):\n diff[i] = lis[i + 1] - lis[i]\n\ndiff.sort()\n\nfor j in range (nm[0] - 1):\n diff.pop(-1)\n\nprint(np.sum(diff))', 'nm = list(map(int, input().split()))\nlis = list(map(int, input().split()))\n\nlis.sort()\n\nsum = 0\ndiff = []\n\nif nm[1] - nm[0] <= 0:\n print(0)\nelse:\n for i in range (nm[1] - 1):\n diff.append(lis[i + 1] - lis[i])\n\n diff.sort()\n\n if nm[0] != 1:\n for j in range (nm[0] - 2):\n diff.pop(-1)\n\n for k in range (nm[1] - nm [0]):\n sum = sum + diff[k]\n\n print(sum)\n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s159932556', 's185597910', 's720138850', 's344110383'] | [13968.0, 13968.0, 23048.0, 13960.0] | [77.0, 131.0, 210.0, 131.0] | [379, 418, 260, 402] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.