fork download
  1. use bignum;
  2.  
  3. $e=0;
  4.  
  5. while(<>){
  6.  
  7. ($n,$m)=split/ /;
  8. ($n or $m) or last; # break if 0 0
  9.  
  10. $f=0;
  11. for $i(1..$n){
  12. $_=<>;
  13. / (\d+) (\d+)$/; # read two numbers to $1 and $2
  14. $m-=$1;
  15. if ($m<0){ $f=1 }
  16. $m+=$2;
  17. }
  18.  
  19. $e++>0 and
  20. print "\n";
  21.  
  22. print $f ? "Fail":"Success";
  23.  
  24. }
Success #stdin #stdout 0.07s 6788KB
stdin
5 10000
Darth Vader: 7500 6000
Ganon: 7500 6000
Goku: 9001 6000
Napoleon: 4000 4000
The Batman: 6000 8000
3 0
Santa Claus: 0 25
Mrs Claus: 0 25
Kris Kringle: 30 10
0 0
stdout
Fail
Success