Advertisement
bai_onzi

mineralWater

Mar 4th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let smallBottles = +gets(); // 1 liter per bottle
  2. let bigBottles = +gets(); // 5 liters per bottle
  3. let capacity = +gets(); // in liters
  4. let bigBottleLiters = 0;
  5.  
  6. let availableSpaceForBigBottles = Math.floor(capacity / 5);
  7. if(availableSpaceForBigBottles < bigBottles){
  8.     bigBottleLiters = availableSpaceForBigBottles;
  9. }else{
  10.     bigBottleLiters = bigBottles;
  11. }
  12.  
  13. let bbLiters = bigBottleLiters * 5;
  14. let availableSpace = capacity - bbLiters;
  15.  
  16. // console.log(totalLiters)
  17. // console.log(availableSpace)
  18.  
  19. if(availableSpace <= smallBottles){
  20.     console.log(availableSpace);
  21. }else{
  22.     console.log('-1');
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement