DiYane

Water Overflow

Jul 28th, 2023 (edited)
722
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. def fill_water_tank(capacity, n, amounts):
  2.     current_liters = 0
  3.  
  4.     for amount in amounts:
  5.         if current_liters + amount > capacity:
  6.             print("Insufficient capacity!")
  7.         else:
  8.             current_liters += amount
  9.  
  10.     print(current_liters)
  11.  
  12. capacity = 255
  13. n = int(input())
  14. amounts = [int(input()) for _ in range(n)]
  15.  
  16. fill_water_tank(capacity, n, amounts)
  17.  
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment