Advertisement
momo3141

Mineral Water

Oct 18th, 2022
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | Source Code | 0 0
  1. let input = [
  2. '0',
  3. '3',
  4.  
  5. ];
  6. let print = this.print || console.log;
  7. let gets = this.gets || ((arr, index) => () => arr[index++])(input, 0);
  8. //Code
  9. let smallBottles = +gets();
  10. let bigBottles = +gets();
  11. let capacity = +gets();
  12. let fiveCapacity = parseInt(capacity/5)
  13. if (((bigBottles>=fiveCapacity&&(capacity-fiveCapacity*5)<=smallBottles)&& bigBottles !==0)){
  14. print (capacity-fiveCapacity*5)
  15. } else if ((bigBottles<=fiveCapacity&&(capacity-bigBottles*5)<=smallBottles)&& bigBottles !==0) {
  16. print (capacity-fiveCapacity*5)
  17. } else if (bigBottles==0 && smallBottles>=capacity){
  18. print(capacity)
  19. } else {
  20. print(-1)
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement