Advertisement
Guest User

WaterOverFlow

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