| 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 100Lulzim 10
 Ridvan 10
 Sali 100
 Jozefina 20
 Jorida 5
 
 | Sample Input 2 
 
4 100Lulzim 10
 Lulzim 10
 Lulzim 10
 Lulzim 10
 
 |  | Sample Output 1 
 
Sali
 | Sample Output 2 
 
60
 |   Explanation 1: 
 
When Sali hits the bunker, he applies a 
force greater than 80 units, and the 
bunker is demolished.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.
  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.
 
 Для отправки решений необходимо выполнить вход.
 
 
 |