Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int iterations = int.Parse(Console.ReadLine());
- byte capacity = 255;
- byte sum = 0;
- for (int i = 0; i < iterations; i++)
- {
- short liters = short.Parse(Console.ReadLine());
- if (liters <= capacity - sum)
- {
- sum += (byte)liters;
- }
- else
- {
- Console.WriteLine("Insufficient capacity!");
- }
- }
- Console.WriteLine(sum);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement