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

Envío 4096

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: TacoMeister
  • Fecha: 2021-05-11 15:58:29 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.186 s 16 KBi
#2
Correcto
0.141 s 14 KBi
#3
Correcto
0.088 s 17 KBi
#4
Correcto
0.186 s 14 KBi
#5
Correcto
0.16 s 12 KBi
#6
Correcto
0.199 s 16 KBi
#7
Correcto
0.12 s 16 KBi
#8
Incorrecto
0.171 s 12 KBi
#9
Correcto
0.18 s 14 KBi
#10
Correcto
0.133 s 16 KBi
#11
Correcto
0.134 s 18 KBi
#12
Correcto
0.179 s 18 KBi
#13
Correcto
0.203 s 19 KBi
#14
Tiempo límite excedido
1.038 s 123 KBi
#15
Tiempo límite excedido
1.032 s 125 KBi
#16
Tiempo límite excedido
1.126 s 97 KBi
#17
Correcto
1.0 s 123 KBi
#18
Tiempo límite excedido
1.104 s 97 KBi
#19
Tiempo límite excedido
1.041 s 97 KBi
#20
Tiempo límite excedido
1.092 s 97 KBi
Puntos totales: 65 / 100

Código

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int partir = 0;
        int size = scanner.nextInt();
        int acumulador=0,x=0;
        long [] numbers= new long[size];
        for(int i=0;i<size;i++){
            numbers[i]=scanner.nextLong();
        }
        for(int u=0; u<size; u++){
            acumulador += numbers[u];
            if(acumulador>0){
                x=0;
                partir=1;
                for(int j=u+1;j<size;j++){
                    x += numbers[j];
                }
                if(x<0){
                    System.out.println(u+1);
                    break;
                }
            }
        }
        if(acumulador<=0){
            System.out.println("Impossible");
        }
    }
}