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

Envío 1501

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: c4rlosc7
  • Fecha: 2020-10-29 02:50:41 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.122 s 13 KBi
#2
Correcto
0.13 s 13 KBi
#3
Correcto
0.132 s 13 KBi
#4
Correcto
0.135 s 13 KBi
#5
Correcto
0.129 s 13 KBi
#6
Correcto
0.127 s 13 KBi
#7
Correcto
0.125 s 13 KBi
#8
Correcto
0.118 s 13 KBi
#9
Correcto
0.128 s 13 KBi
#10
Correcto
0.119 s 13 KBi
#11
Correcto
0.116 s 13 KBi
#12
Correcto
0.169 s 16 KBi
#13
Correcto
0.199 s 16 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/openjdk13/bin/java Main
0.955 s 125 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/openjdk13/bin/java Main
0.856 s 125 KBi
#16
Tiempo límite excedido
1.042 s 107 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/openjdk13/bin/java Main
0.837 s 125 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/openjdk13/bin/java Main
0.866 s 125 KBi
#19
Tiempo límite excedido
1.021 s 102 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/openjdk13/bin/java Main
0.941 s 125 KBi
Puntos totales: 65 / 100

Código

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean loop = false;

        int [] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int left = 0, right = 0;
        for (int i = 0; i < n; i++) {
            right += a[i];
        }

        for (int p = 0; p < n; p++) {
            if (left > 0 && right < 0) {
                System.out.println(p);
                loop = true;
                break;
            }
            left += a[p];
            right -= a[p];
        }
        if (!loop) {
            System.out.println("Impossible");
        }
	}
}