HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Repetition (Loops) > problem:


50815 - Breaking the Bunker

Guest
• Review clarifications (1)

Volume problems

• 50897 - Prime Number
• 50901 - Sum of Cubes-1
• 50957 - Divisible by 3
• 51115 - Pascal Triangle
• 50898 - Draw the Pattern
• 51116 - The Star Triangle
• 50896 - Sum of Even Numbers
• 50815 - Breaking the Bunker
• 50899 - How Many Years
• 50806 - TVSH
• 51078 - Max trade
• 50820 - Post Office
• 50807 - Euro to Leke
• 50810 - Print Office
• 50952 - Derby Tirana
• 50871 - Harmonic Mean

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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