█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 6425

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: Camilo15
  • Fecha: 2022-07-05 19:30:08 UTC (Hace más de 1 año)
Caso # Resultado Tiempo Memoria
#1
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#2
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#3
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#4
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#5
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#6
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#7
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#8
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#9
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#10
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#11
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#12
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#13
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#14
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#15
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#16
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#17
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#18
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#19
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
#20
Error de compilación
                      Main.java:27: error: incompatible types: unexpected return value
				return "";}
				       ^
Main.java:32: error: incompatible types: unexpected return value
			return "";
			       ^
2 errors

                    
Puntos totales: 0 / 100

Código

import java.util.*;
public class Main {

    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();  
		
int s= 0;
		int [] array = new int [n];
		for(int i =0; i<n; i++){
                        
		  	array[i]= sc.nextInt();
                        s+=array[i];
		}
		
            int leftSide=0;
            int rightSide=s;
           
		
			for(int i =0; i<n; i++){
				
				leftSide+=array[i];
				rightSide-=array[i];
				
				if(leftSide>0 && rightSide<0){ 
				System.out.println(i+1);
				return "";}
		  
			}
		
			System.out.println("Impossible");
			return "";
		}
           
}