307930: CF1437C. Chef Monocarp
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Chef Monocarp
题意翻译
有$n$到菜品被放入了一个烤炉中,每到菜品都有一个最佳取出的时间$t_i$。现在按照一定顺序把菜品从烤炉中取出,每到菜品都有可能因为不在最佳时间被取出而造成不美味,定义这个不美味度为$|T-t_i|$,其中$T$是取出的时刻。求把所有菜品都取出来的最小不美味度。题目描述
Chef Monocarp has just put $ n $ dishes into an oven. He knows that the $ i $ -th dish has its optimal cooking time equal to $ t_i $ minutes. At any positive integer minute $ T $ Monocarp can put no more than one dish out of the oven. If the $ i $ -th dish is put out at some minute $ T $ , then its unpleasant value is $ |T - t_i| $ — the absolute difference between $ T $ and $ t_i $ . Once the dish is out of the oven, it can't go back in. Monocarp should put all the dishes out of the oven. What is the minimum total unpleasant value Monocarp can obtain?输入输出格式
输入格式
The first line contains a single integer $ q $ ( $ 1 \le q \le 200 $ ) — the number of testcases. Then $ q $ testcases follow. The first line of the testcase contains a single integer $ n $ ( $ 1 \le n \le 200 $ ) — the number of dishes in the oven. The second line of the testcase contains $ n $ integers $ t_1, t_2, \dots, t_n $ ( $ 1 \le t_i \le n $ ) — the optimal cooking time for each dish. The sum of $ n $ over all $ q $ testcases doesn't exceed $ 200 $ .
输出格式
Print a single integer for each testcase — the minimum total unpleasant value Monocarp can obtain when he puts out all the dishes out of the oven. Remember that Monocarp can only put the dishes out at positive integer minutes and no more than one dish at any minute.
输入输出样例
输入样例 #1
6
6
4 2 4 4 5 2
7
7 7 7 7 7 7 7
1
1
5
5 1 2 4 3
4
1 4 4 4
21
21 8 1 4 1 5 21 1 8 21 11 21 11 3 12 8 19 15 9 11 13
输出样例 #1
4
12
0
0
2
21