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

Разделы > Поиск > задача:


50451 - Processing Cost

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

Задачи раздела

• 51055 - The competition
• 51077 - Grades Histogram
• 51057 - Number of students
• 51046 - The biggest number
• 50535 - Image Compression
• 50450 - Last Appereance of a Number
• 50457 - The Number of Winners
• 50453 - The Cubic Difference
• 50451 - Processing Cost
• 50459 - The Biggest Digit
• 50538 - Sum of kth Diagonal
• 50465 - How many students have p...
• 50378 - Sum of the given digits
• 50470 - Close Pairs - Revised
• 50784 - Top Growing Company
• 50458 - Weekly Report
• 50478 - Letter Grades

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

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

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

Processing Cost

Assume that processing a list of items costs the sum of differences between the item and the max value in that series. For example if we are given the series: 5 3 2 7, thus, the max of this series is 7. Then, the processing cost of it is

= (7-5) + (7-3) + (7-2) + (7-7)
= 2 + 4 + 5 + 0 = 11.

Question: Write a program that is going to read n rows of m element series and then the program will find the minimum processing cost.

Input specification
In the first line, you will be given two numbers (n and m). Then, in the following n lines, you will be given m integers which are between -20000 and 20000 where n and m are between 1 and 20000

Output specification
Show one integer: Minimum processing cost.

Sample Input I   
3 4
7 1 7 9
4 10 8 8
9 2 6 3
Sample Input II   
2 4
5 3 2 7
5 13 2 17
Sample Output I   
10
Sample Output II   
11

Explanation:
In sample input 1, there are 3 rows with 4 elements. The max of first row is 9 and the processing cost of it 12. The max of the second row is 10 with a total processing cost of 10 (6+0+2+2). Then the third series has the max of 9. And it’s processing cost is 16. So, the second row has the minimum processing cost: 10.

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

www.contester.ru