ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Турниры > CEN_114 Midterm B > задача:


12. 50749 - Min Distance

CEN_114 Midterm B

Старт: 14.мая.2020 в 00:00:01
Финиш: 31.мая.2020 в 23:59:59
Турнир завершён!
• Турнирная таблица

Гость
• Вопросы к жюри (2)

Задачи турнира

• 10. 51095 - Normal and Trace
• 11. 51089 - Multiply a row and add i...
• 12. 50749 - Min Distance
• 13. 51124 - Easy Tiae words
• 14. 51136 - Class Average 2
• 15. 50734 - Product Info (In Srt)
• 2. 50453 - The Cubic Difference
• 3. 50346 - The Biggest Date
• 5. 50380 - Sum of the Numbers in t...
• 6. 50443 - Dajte Express
• 7. 50496 - Falling Bricks

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Min Distance

If you have the series 10 7 3 5: The difference between the consecutive numbers is:

  • The difference between 10 and 7 is 3
  • The difference between 7 and 3 is 4
  • The difference between 3 and 5 is 2
Then, the sum of consecutive differences is 9. If you calculate sum of consecutive differences of the same series when they are in this order: 3 7 10 5:
  • The difference between 3 and 7 is 4
  • The difference between 7 and 10 is 3
  • The difference between 10 and 5 is 5
Then, the sum of consecutive differences is 12.

Question: You are asked to read a sequence of numbers and find the sum of consecutive differences such that the result is minimum.

Input specification
You will be given an integer (n) number of numbers where 0 ≤ n ≤ 10,000. Then, in the following n lines you will be given n integers where each number is between -100,000 and +100,000.

Output specification
Show one number: minimum sum of differences between consecutive numbers.

Sample Input I
6
1
5
3
4
7
2
Sample Output I
6



Для отправки решений необходимо выполнить вход.

www.contester.ru