One of the SBU ACM teams, Triangulum wants to travel to Kanpur for an important regional…
- User
One of the SBU ACM teams, Triangulum wants to travel to Kanpur for an important regional contest. They should travel by bus and as you know it could be an incredibly boring trip. During their trip they need to rest in some hotels. There are N hotels in the path from Tehran to Kanpur. They should choose some hotels to take a rest at (maybe more than one night), and finally they must rest at N N'th hotel. If they travel for d D distances between two hotels they should tolerate ∣ d
144 ∣ ∣D−144∣ unit of difficulties. Given the distance of each hotel from Tehran, your task is to help them to choose some hotels in order to minimize total difficulties as much as possible.
For more clarification, see sample inputs and outputs.
input Your program will be tested on one or more test cases. The first line of the input will be a single integer T ( T ≤ 30 ) T(T≤30), the number of test cases. The first line of each test case will contain integers N N, the number of hotels. Next line contains N N space separated integer numbers, each indicating d i d i , distance from Tehran to i i'th hotel (in increasing order). d i < 10,000 d i <10000 and N ≤ 20 N≤20.
output For each test case print a single line containing minimum total difficulties.
examples Sample entry 1 3 1 10 2 120 144 4 10 14 20 21 Plain text Sample output 1 134 0 123 write in c++
- Assistant