Teo_Yanchev

WaterOverFlow - C# - Fundamentals

Aug 19th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _07.WaterOverflow
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int n = int.Parse(Console.ReadLine());
  10.  
  11. int littersFilled = 0;
  12. for (int i = 0; i < n; i++)
  13. {
  14. int liters = int.Parse(Console.ReadLine());
  15.  
  16. if (liters + littersFilled > 255)
  17. {
  18. Console.WriteLine("Insufficient capacity!");
  19. }
  20. else
  21. {
  22. littersFilled += liters;
  23. }
  24. }
  25. Console.WriteLine(littersFilled);
  26. }
  27. }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment