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

Турниры > SEM 2 - W4 > задача:


2nd-4. 50513 - Climbing Up the Stairs

SEM 2 - W4

Старт: 28.мар.2023 в 16:41:52
Финиш: 04.апр.2023 в 20:41:52
Турнир завершён!
• Турнирная таблица

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

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

• 50730 - The largest product
• 50731 - The largest product (2)
• 50732 - Sorting
• 2012-11-20. 50792 - Studenti me ...
• 2nd-4. 50513 - Climbing Up the...

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

Если у вас есть предложения или пожелания по работе 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