{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eAs you might already know, Ada the Ladybug is a farmer. She grows vegetables. At the moment, all her vegetables are in one furrow. She is going to replant them into a few new furrows (while keeping the order of the vegetables).\u003c/p\u003e\r\n\u003cp\u003eThe total cost of growing the vegetables will be equal to the sum of absolute differences between neighboring vegetables. Ada wants to minimize the cost, can you help her?\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eThe first line of input contain \u003cstrong\u003e1 ≤ T ≤ 500 \u003c/strong\u003e test-cases.\u003c/p\u003e\r\n\u003cp\u003eThe first line of each test-case contains two integers \u003cstrong\u003e N, K 1 ≤ N ≤ 2000, 1 ≤ K ≤ 20\u003c/strong\u003e\u003c/p\u003e\r\n\u003cp\u003eThe next line contains \u003cstrong\u003eN\u003c/strong\u003e integers \u003cstrong\u003e0 ≤ A\u003csub\u003ei\u003c/sub\u003e \u0026lt; 10\u003csup\u003e4\u003c/sup\u003e\u003c/strong\u003e, the costs of vegetables.\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003eNOTE:\u003c/strong\u003e The number of test-cases varies depending on size of array (the longest array won\u0027t be a single file more than once).\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each test-cases, print the minimal costs.\u003c/p\u003e\r\n\u003ch3\u003eExample\u003c/h3\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n4 2\r\n1 2 5 6\r\n5 1\r\n1 2 5 7 11\r\n6 3\r\n1 3 1 3 1 3\r\n8 2\r\n1 6 2 5 1 6 2 5\r\n5 3\r\n1 9 15 4 11\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n10\r\n0\r\n6\r\n5\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003ch3\u003eAdditional Information\u003c/h3\u003e\r\n\u003cpre\u003eTEST-CASE-1:\r\n1 2\r\n5 6\r\nTEST-CASE-2:\r\n1 2 5 7 11\r\nTEST-CASE-3:\r\n1 1 1\r\n3 3 3\r\n\r\nTEST-CASE-4:\r\n1 2 1 2\r\n6 5 6 5\r\nTEST-CASE-5:\r\n1 4\r\n9 11\r\n15\r\n\u003c/pre\u003e\r\n\u003ch3\u003eExample Input 2\u003c/h3\u003e\r\n\u003cpre\u003e1 \r\n7 2 \r\n2 5 7 4 8 8 4 \r\n\u003c/pre\u003e\r\n\u003ch3\u003eExample Output 2\u003c/h3\u003e\r\n\u003cpre\u003e5\r\n\u003c/pre\u003e\r\n\u003ch3\u003eExample Input 3\u003c/h3\u003e\r\n\u003cpre\u003e1\r\n10 2\r\n4 5 4 3 4 3 2 3 2 3\r\n\u003c/pre\u003e\r\n\u003ch3\u003eExample Output 3\u003c/h3\u003e\r\n\u003cpre\u003e4\r\n\u003c/pre\u003e\n\u003c/div\u003e"}}]}