HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > CEN111 Homeworks 2013-2015 > problem:


15-FallPr-80. 50815 - Breaking the Bunker

CEN111 Homeworks 2013-2015

Start: Jan.10.2015 at 10:00:00 AM
Finish: Jan.10.2015 at 03:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (1)

Contest problems

• 15-FallHW-2. 50821 - Derivative of ...
• 15-FallHW-3. 50822 - Linked List
• 15-FallHW-4. 50823 - Secret Number
• 15-FallHW-5. 50824 - Sum of Group...
• 15-FallHW-6. 50825 - Drawing Polygon
• 15-FallPr-10. 50808 - Total Distance...
• 15-FallPr-50. 50812 - Total Discount...
• 15-FallPr-70. 50814 - Buying Books f...
• 15-FallPr-80. 50815 - Breaking ...
• 15-FallRE-10. 50853 - Parking Place
• 15-FallRE-20. 50854 - Area of Trian...

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