Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.077 s | 13 KBi |
#2 |
Correcto
|
0.079 s | 13 KBi |
#3 |
Correcto
|
0.073 s | 14 KBi |
#4 |
Correcto
|
0.085 s | 13 KBi |
#5 |
Correcto
|
0.072 s | 13 KBi |
#6 |
Correcto
|
0.093 s | 10 KBi |
#7 |
Correcto
|
0.094 s | 10 KBi |
#8 |
Correcto
|
0.075 s | 13 KBi |
#9 |
Correcto
|
0.077 s | 13 KBi |
#10 |
Correcto
|
0.079 s | 13 KBi |
#11 |
Correcto
|
0.087 s | 10 KBi |
#12 |
Correcto
|
0.092 s | 14 KBi |
#13 |
Correcto
|
0.095 s | 14 KBi |
#14 |
Correcto
|
0.459 s | 49 KBi |
#15 |
Correcto
|
0.457 s | 49 KBi |
#16 |
Correcto
|
0.477 s | 51 KBi |
#17 |
Correcto
|
0.527 s | 36 KBi |
#18 |
Correcto
|
0.423 s | 48 KBi |
#19 |
Correcto
|
0.452 s | 47 KBi |
#20 |
Correcto
|
0.501 s | 53 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+1<N;i++) if(left[i]>0 && right[i+1]<0) { System.out.println(i + 1); return; } System.out.println("Impossible"); } } }