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

Турниры > IMPC-2014-15 Questions > задача:


4th-2. 50524 - Elevator

IMPC-2014-15 Questions

Старт: 22.ноя.2014 в 15:00:00
Финиш: 22.ноя.2014 в 20:00:00
Турнир завершён!
• Турнирная таблица

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

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

• 2nd-5. 50793 - Top M Customers
• 2nd-6. 50486 - Problems and Progr...
• 3rd-2. 50405 - Accounts Receivable
• 3rd-3. 50474 - Sum of Two Primes
• 3rd-4. 50406 - Draw Pattern 178
• 3rd-5. 50415 - The Scientist
• 3rd-6. 50695 - Longest link between...
• 4th-1. 50491 - Brokers
• 4th-2. 50524 - Elevator
• 4th-3. 50535 - Image Compression
• 4th-6. 50536 - Epoka Furgon Shpk
• Ind_01-10. 50752 - Student Groups
• Ind_01-20. 50416 - Placing Domino...
• Ind_01-30. 50764 - Fast Typing Co...
• Ind_01-50. 50718 - Elevator
• Ind_02-10. 50497 - Falling Bricks - ...
• Ind_02-20. 50745 - Bitonic Sequence

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

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

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

Elevator

The university has a new building. For the economic difficulties, the elevator just carries people from ground floor to the upper floors. Thus people walk down when returning. The people are grouped according to the floor numbers they want to go. Then, until the elevator is full. The elevator climbs up till the last person's destination floor. Then, it returns back to the ground floor. To give a fast service, the elevator starts lifting people who wants to go to the lowest floors.

Question: Write a program that is going to read the people and elevator information, then your program will calculate the total number of floors that the elevator has traveled.

Input specification
You will be given two integers in the first line: the number of floors (n) and the capacity of the elevator (cap: the number of people it can carry at once). Then in the following n lines you will be given integers which are between 0 and 1000. n is an integer between 1 and 30000 and cap is between 1 and 1000.

Output specification
Show one integer: the total number of floors that the elevator has climbed.

Sample Input I
5 6
4
3
8
2
0
Sample Output I
9

Explanation:
There five floors and elevator can carry at most 6 people. And, there are 4 people waiting for the first floor, 3 people waiting for the second floor, etc.

  • On the first run, the elevator takes 4 people for the first floor and 2 people for the second floor. And it leaves them to their floors: climbed up to the second floor.
  • On the second run, it takes 1 person for the second floor and 5 people for the third floor: climbed up to the third floor; and the total number of floors climbed is 5.
  • On the last run, it takes 3 people for the third floor and 2 people for the fourth floor: climbed up to the 4th floor; and the total is 9.


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

www.contester.ru