Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.154 s | 16 KBi |
#2 |
Correcto
|
0.159 s | 16 KBi |
#3 |
Correcto
|
0.17 s | 16 KBi |
#4 |
Correcto
|
0.166 s | 16 KBi |
#5 |
Correcto
|
0.157 s | 16 KBi |
#6 |
Correcto
|
0.153 s | 16 KBi |
#7 |
Correcto
|
0.165 s | 16 KBi |
#8 |
Correcto
|
0.153 s | 16 KBi |
#9 |
Correcto
|
0.163 s | 16 KBi |
#10 |
Correcto
|
0.175 s | 16 KBi |
#11 |
Correcto
|
0.332 s | 14 KBi |
#12 |
Correcto
|
0.177 s | 17 KBi |
#13 |
Correcto
|
0.202 s | 17 KBi |
#14 |
Esperando resultado...
|
||
#15 |
Correcto
|
0.852 s | 81 KBi |
#16 |
Esperando resultado...
|
||
#17 |
Esperando resultado...
|
||
#18 |
Correcto
|
0.898 s | 89 KBi |
#19 |
Esperando resultado...
|
||
#20 |
Tiempo límite excedido
|
1.179 s | 105 KBi |
import java.util.Scanner; import java.util.Arrays; class Main { private static final Scanner scanner = new Scanner(System.in); public static void main(String args[]) { int n = Integer.parseInt(scanner.nextLine()); // Number of elements in array long[] a = Arrays.stream(scanner.nextLine().split(" ")).map(Long::parseLong).mapToLong(x -> x).toArray(); // Array int result = split(a, n); System.out.println(result < 0 ? "Impossible" : result); scanner.close(); } private static int split(long[] a, int n) { long right = Arrays.stream(a).sum(); long left = 0; for (int i = 0; i < n; i++) { left += a[i]; if (right - left < 0 && left > 0) { return i + 1; } } return -1; } }