لینک‌های مفید برای شرکت در مسابقه:

در طول مسابقه، می‌توانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.

F – Road to Kanpur


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

One of the SBU ACM teams, Triangulum wants to trip 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 take rest in some hotels. There are N hotels in the path of Tehran to Kanpur. They should choose some hotels to take a rest at (maybe more than one night), and finally they must rest at NN’th hotel. If they travel for DD distances between two hotels they should tolerate D144|D-144| unit of difficulties. Given 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.

ورودی🔗

Your program will be tested on one or more test cases. The first line of the input will be a single integer T(T30)T(T \le 30), the number of test cases. The first line of each test case will contain integers NN, the number of hotels. Next line contains NN space separated integer numbers, each indicating DiD_i , distance from Tehran to ii’th hotel (in increasing order).Di<10000D_i < 10000 and N20N ≤ 20.

خروجی🔗

For each test case print a single line containing minimum total difficulties.

مثال‌ها🔗

ورودی نمونه ۱🔗

3
1
10
2
120 144
4
10 14 20 21
Plain text

خروجی نمونه ۱🔗

134
0
123
Plain text
ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.