Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.179 s | 15 KBi |
#2 |
Correcto
|
0.183 s | 16 KBi |
#3 |
Correcto
|
0.163 s | 15 KBi |
#4 |
Correcto
|
0.323 s | 12 KBi |
#5 |
Correcto
|
0.186 s | 16 KBi |
#6 |
Correcto
|
0.153 s | 15 KBi |
#7 |
Correcto
|
0.152 s | 16 KBi |
#8 |
Correcto
|
0.167 s | 16 KBi |
#9 |
Correcto
|
0.345 s | 16 KBi |
#10 |
Correcto
|
0.305 s | 12 KBi |
#11 |
Correcto
|
0.191 s | 16 KBi |
#12 |
Correcto
|
0.178 s | 15 KBi |
#13 |
Correcto
|
0.183 s | 16 KBi |
#14 |
Correcto
|
0.198 s | 16 KBi |
#15 |
Correcto
|
0.19 s | 16 KBi |
#16 |
Correcto
|
0.203 s | 16 KBi |
#17 |
Correcto
|
0.584 s | 35 KBi |
#18 |
Esperando resultado...
|
||
#19 |
Correcto
|
0.532 s | 35 KBi |
#20 |
Esperando resultado...
|
||
#21 |
Correcto
|
0.728 s | 29 KBi |
#22 |
Esperando resultado...
|
||
#23 |
Correcto
|
0.478 s | 29 KBi |
#24 |
Correcto
|
0.483 s | 30 KBi |
import java.util.Scanner; class Main { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = Integer.parseInt(scanner.nextLine()); long[] a = new long[n]; int i = 0; for (String s : scanner.nextLine().split(" ")) { a[i] = Long.parseLong(s); i++; } long acummulator = a[0]; long best = acummulator; for (i = 1; i < n; i++) { acummulator = Math.max(a[i], acummulator + a[i]); best = Math.max(best, acummulator); } System.out.println(best); scanner.close(); } }