Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.081 s | 13 KBi |
#2 |
Correcto
|
0.082 s | 13 KBi |
#3 |
Correcto
|
0.082 s | 13 KBi |
#4 |
Correcto
|
0.079 s | 13 KBi |
#5 |
Correcto
|
0.087 s | 18 KBi |
#6 |
Correcto
|
0.091 s | 19 KBi |
#7 |
Correcto
|
0.074 s | 13 KBi |
#8 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 4 out of bounds for length 4 at Main.main(Main.java:25) |
0.077 s | 13 KBi |
#9 |
Correcto
|
0.089 s | 15 KBi |
#10 |
Correcto
|
0.073 s | 14 KBi |
#11 |
Correcto
|
0.07 s | 13 KBi |
#12 |
Correcto
|
0.106 s | 28 KBi |
#13 |
Correcto
|
0.1 s | 14 KBi |
#14 |
Correcto
|
0.461 s | 50 KBi |
#15 |
Correcto
|
0.458 s | 49 KBi |
#16 |
Correcto
|
0.463 s | 50 KBi |
#17 |
Correcto
|
0.448 s | 51 KBi |
#18 |
Correcto
|
0.478 s | 50 KBi |
#19 |
Correcto
|
0.46 s | 49 KBi |
#20 |
Correcto
|
0.495 s | 52 KBi |
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Throwable { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; for(String ln; (ln=in.readLine())!=null;) { int N = Integer.parseInt(ln); st = new StringTokenizer(in.readLine()); int[] values = new int[N]; for(int i=0;i<N;i++) values[i] = Integer.parseInt(st.nextToken()); int[] left = new int[N]; int[] right = new int[N]; left[0] = values[0]; right[N-1] = values[N-1]; for(int i =1, j=N-1; i<N;i++,j--) { left[i] = left[i-1] + values[i]; right[j-1] = right[j] + values[j-1]; } for(int i =0; i<N;i++) if(left[i]>0 && right[i+1]<0) { System.out.println(i + 1); return; } System.out.println("Impossible"); } } }