bullit3189

Water Overflow - DataTypesTFJan19

Jan 30th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5.  
  6. public class Program
  7. {
  8. public static void Main()
  9. {
  10. int capacity = 255;
  11. int n = int.Parse(Console.ReadLine());
  12. int poured = 0;
  13.  
  14. for (int i=0; i<n; i++)
  15. {
  16. int currQuantity = int.Parse(Console.ReadLine());
  17.  
  18. if (currQuantity + poured > capacity)
  19. {
  20. Console.WriteLine("Insufficient capacity!");
  21. continue;
  22. }
  23. else
  24. {
  25. poured += currQuantity;
  26. }
  27. }
  28. Console.WriteLine(poured);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment