Advertisement
Guest User

Untitled

a guest
May 25th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Wateroverflow {
  4. public static void main(String[]args){
  5. Scanner sc=new Scanner(System.in);
  6.  
  7. int liters=255;
  8. int n=Integer.parseInt(sc.nextLine());
  9. int sumL=0;
  10.  
  11. for(int i=1;i<n;i++){
  12. int inputL=Integer.parseInt(sc.nextLine());
  13. sumL+=inputL;
  14. if(sumL>liters){
  15. System.out.print("Insufficient capacity!");
  16. sumL-=inputL;
  17. }else{
  18. sumL+=inputL;
  19. }
  20. }
  21. System.out.printf("%n%d",sumL);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement