Advertisement
Radost09

Water Overflow

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