C# Fundamentals - Data Types and Variables - Exercise - 07. Water Overflow
Здравейте,
Може ли малко помощ за тази задачка? Judje ми дава 85/100. Примерните тестове ми излизат.
Условие:
You have a water tank with capacity of 255 liters. On the next n lines, you will receive liters of water, which you have to pour in your tank. If the capacity is not enough, print “Insufficient capacity!” and continue reading the next line. On the last line, print the liters in the tank.
Input
The input will be on two lines:
- On the first line, you will receive n – the number of lines, which will follow
- On the next n lines – you receive quantities of water, which you have to pour in the tank
Output
Every time you do not have enough capacity in the tank to pour the given liters, print:
Insufficient capacity!
On the last line, print only the liters in the tank.
Constraints
- n will be in the interval [1…20]
- liters will be in the interval [1…1000]
Examples
Input |
Output |
|
Input |
Output |
5 20 100 100 100 20 |
Insufficient capacity! 240 |
1 1000
|
Insufficient capacity! 0 |
Input |
Output |
|
Input |
Output |
7 10 20 30 10 5 10 20 |
105 |
4 250 10 20 40 |
Insufficient capacity! Insufficient capacity! Insufficient capacity! 250 |
Моето решение : https://pastebin.com/Mvy0UBnv
Задачата в Judge : https://judge.softuni.bg/Contests/Practice/Index/1205#6
Благодаря предварително. :)
Много благодаря. Допълнително съм си била усложнила решението. :)
https://pastebin.com/3e8hak0h
Java е кода, но все пак вижте логиката : )
Благодаря :)