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

Сборники > Kovrov IT > задача:


50513 - Climbing Up the Stairs

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

Задачи сборника

• 50515 - Lines - Revisited
• 50999 - Overlapping Trips
• 50507 - Sequential Numbers
• 50449 - The biggest result
• 50434 - Row Min Subtraction
• 50442 - Polynomial Addition
• 50869 - Birthday Celebration
• 50870 - ZScore normalization
• 50513 - Climbing Up the Stairs
• 50821 - Derivative of an array
• 50854 - Area of Triangle Revised
• 50520 - Filling a Matrix Randomly
• 51019 - Finding the hidden message
• 50497 - Falling Bricks - Revisited
• 51002 - The most successful classes
• 50847 - The first m trains to leave
• 50669 - Area of an Irregular Polygon

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

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

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

Climbing Up the Stairs

Mr. Shahin Celmeta works as a postman and distributes mails or boxes to the people. He has to go through apartments from different floors of different buildings. All apartment buildings have elevators, but Mr. Celmeta uses the elevator if the next box to deliver is more than two floors above. That is if the next box is just one or two floors above, he uses stairs; otherwise, he uses the elevator.

Question: Read the mail information and show how many floors does he climb.

Input specification
The floor numbers are between 0 and 200. Information for every building is given in a separate line ending with a negative number. And, there are at most 200 integers in every line which are separated by space. The information ends with a negative number at the beginning of line.

Output specification
Show one integer: total number floors he climbs.

Sample Input I
3 6 5 9 6 -1
3 12 5 6 12 14 3 -2
-1
Sample Output I
8

Explanation: There are two buildings. And, there are 5 mails for the first building; and, 7 mails for the second building.

For the second building, when you sort the list, it becomes
  3 3 5 6 12 12 14
The first box has to be delivered to the third floor. Thus, he uses the elevator. After the third floor, he uses the stairs to go to floors five and six. For floor 12, he uses elevator. And then, he uses stairs to climb up the floor 14. As a result, he climbs 5 floors for the second building; and 3 floors for the first building.



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

www.contester.ru