SimeonTs

SUPyF2 D.Types and Vars Exercise - 07. Water Overflow

Sep 27th, 2019
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. """
  2. Data Types and Variables - Exercise
  3. Check your code: https://judge.softuni.bg/Contests/Practice/Index/1722#6
  4.  
  5. SUPyF2 D.Types and Vars Exercise - 07. Water Overflow
  6. Problem:
  7. You have a water tank with capacity of 255 liters.
  8. On the next n lines, you will receive liters of water, which you have to pour in your tank.
  9. If the capacity is not enough, print "Insufficient capacity!" and continue reading the next line. On the last line,
  10. print the liters in the tank.
  11. Input
  12. The input will be on two lines:
  13. • On the first line, you will receive n – the number of lines, which will follow
  14. • On the next n lines – you receive quantities of water, which you have to pour in the tank
  15. Output
  16. Every time you do not have enough capacity in the tank to pour the given liters, print:
  17. Insufficient capacity!
  18. On the last line, print only the liters in the tank.
  19. Constraints
  20. • n will be in the interval [1…20]
  21. • liters will be in the interval [1…1000]
  22. Examples:
  23. INPUT:
  24. 5
  25. 20
  26. 100
  27. 100
  28. 100
  29. 20
  30. OUTPUT:
  31. Insufficient capacity!
  32. 240
  33.  
  34. INPUT:
  35. 1
  36. 1000
  37. OUTPUT:
  38. Insufficient capacity!
  39. 0
  40. """
  41. capacity = 0
  42. for each_time in range(int(input())):
  43.     liters = int(input())
  44.     if capacity + liters > 255:
  45.         print("Insufficient capacity!")
  46.     else:
  47.         capacity += liters
  48. print(capacity)
Add Comment
Please, Sign In to add comment