o_ignatov

more_exercises_03

Jun 2nd, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _03_water_overflow
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int litresFilled = 0;
  15. for (int i = 0; i < n; i++)
  16. {
  17. int fillWith = int.Parse(Console.ReadLine());
  18. if (fillWith > 255 - litresFilled)
  19. {
  20. Console.WriteLine("Insufficient capacity!");
  21. }
  22. if (fillWith <= 255 - litresFilled)
  23. {
  24. litresFilled += fillWith;
  25. }
  26.  
  27. }
  28. Console.WriteLine(litresFilled);
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment