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

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


50815 - Breaking the Bunker

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

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

• 50238 - The smallest number
• 51059 - Football teams
• 51058 - Third grade students
• 51060 - Public Transportation
• 50483 - Group Total
• 50331 - Number of Numbers over A...
• Raporti Javor
• 50861 - The largest Student Group
• 50815 - Breaking the Bunker
• 50437 - Age Labeling
• 50500 - Find Student
• 50786 - Top Question
• 50788 - Eight Puzzle
• 50504 - School contest
• 50787 - Expected Value
• 50859 - Low performance
• 50785 - Swimming Contest

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

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

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

Q1

During the latest protest in Albania, there were some people who tried to destroy a bunker by hitting it with different tools. Assuming that the bunker can be destroyed if a total force of X units is applied into it, some protesters contribute to its demolishment by hitting it in a certain order with different magnitudes. Each of their hits makes the bunker's structure weaker until it is completely destroyed. Each of the hits subtracts from the total force X the magnitude of the current hit.

Question: Given the total force needed to demolish the bunker, the number of protesters, the magnitude and the order in which they hit the bunker, find the name of the person who destroys the bunker completely or if it is not yet demolished, write how much force should be still applied on it in order to destroy it completely.

Input specification
You will be first given an integer n (where 1 <= n <= 1000) and n represents the number of protesters that want to hit the bunker. Then you will be given another integer f (where 50 <= f <= 1000) and f represents the total force that should be applied on the bunker in order to demolish it. Then in the following n lines, you will be a given a string (at most 10 characters) which represents the name of each protester and an integer d (1 <= d <= 100) where d represents the force that the hit of the current protester will apply on the bunker.

Output specification
Show the name of the protester who will demolish the bunker completely, or if the bunker is not destroyed yet show the remaining force that should be applied on it.

Note: A protester might like to hit the bunker multiple times.

Sample Input 1
5 100
Lulzim 10
Ridvan 10
Sali 100
Jozefina 20
Jorida 5
Sample Input 2
4 100
Lulzim 10
Lulzim 10
Lulzim 10
Lulzim 10
Sample Output 1
Sali
Sample Output 2
60

Explanation 1:

  • After Lulzim hits the bunker, a force of 90 units is still needed.
  • After Ridvan hits the bunker, a force of 80 units is still needed.
When Sali hits the bunker, he applies a force greater than 80 units, and the bunker is demolished.

Explanation 2:

Lulzim hits the bunker 4 times with a force of 10 units (40 units), so a remaining force of 60 units is needed to demolish the bunker.



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

www.contester.ru