Advertisement
mark79

Water Overflow

May 20th, 2019
1,811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 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 Fundamentals_Water_Overflow
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int n = int.Parse(Console.ReadLine());
  15.             int capacity = 255;
  16.  
  17.             int sum = 0;
  18.  
  19.             for (int i = 0; i < n; i++)
  20.             {
  21.                 int include = int.Parse(Console.ReadLine());
  22.  
  23.                 if (sum + include > capacity)
  24.                 {
  25.                     Console.WriteLine("Insufficient capacity!");
  26.                 }
  27.                 else
  28.                 {
  29.                     sum += include;
  30.                 }
  31.             }
  32.  
  33.             Console.WriteLine(sum);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement