SHOW:
|
|
- or go back to the newest paste.
| 1 | import java.util.Scanner; | |
| 2 | ||
| 3 | public class WaterOverflow_07 {
| |
| 4 | public static void main(String[] args) {
| |
| 5 | Scanner scanner = new Scanner(System.in); | |
| 6 | int capacity = 255; | |
| 7 | int currentLiters = 0; | |
| 8 | int n = Integer.parseInt(scanner.nextLine()); | |
| 9 | for (int i = 1; i <= n; i++) {
| |
| 10 | int pouredLiters = Integer.parseInt(scanner.nextLine()); | |
| 11 | currentLiters += pouredLiters; | |
| 12 | if(currentLiters > capacity) {
| |
| 13 | System.out.println("Insufficient capacity!");
| |
| 14 | currentLiters -= pouredLiters; | |
| 15 | } | |
| 16 | } | |
| 17 | ||
| 18 | System.out.println(currentLiters); | |
| 19 | } | |
| 20 | } | |
| 21 |