Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.w3c.dom.ls.LSOutput;
- import java.util.Scanner;
- public class WaterOverflow {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- int sumOfWater = 0;
- int capacity = 255;
- for (int i = 1; i <= n; i++) {
- int liters = Integer.parseInt(scan.nextLine());
- if (sumOfWater + liters > capacity) {
- System.out.println("Insufficient capacity!");
- } else {
- sumOfWater += liters;
- }
- }
- System.out.println(sumOfWater);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement