Advertisement
mitry99

Untitled

Oct 2nd, 2019
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WaterOverflow {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = scanner.nextInt();
  8.  
  9. int sum = 0;
  10. for (int i = 0; i < n; i++) {
  11. int inputLitres = scanner.nextInt();
  12. if (inputLitres < (255 - sum)) {
  13. sum += inputLitres;
  14.  
  15. } else {
  16. System.out.println("Insufficient capacity!");
  17.  
  18. }
  19. }
  20. System.out.println(sum);
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement