Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.196 s | 16 KBi |
#2 |
Correcto
|
0.17 s | 16 KBi |
#3 |
Correcto
|
0.174 s | 15 KBi |
#4 |
Correcto
|
0.187 s | 16 KBi |
#5 |
Correcto
|
0.176 s | 15 KBi |
#6 |
Correcto
|
0.18 s | 12 KBi |
#7 |
Correcto
|
0.181 s | 12 KBi |
#8 |
Correcto
|
0.165 s | 15 KBi |
#9 |
Correcto
|
0.148 s | 12 KBi |
#10 |
Correcto
|
0.181 s | 12 KBi |
#11 |
Correcto
|
0.185 s | 12 KBi |
#12 |
Correcto
|
0.173 s | 16 KBi |
#13 |
Correcto
|
0.186 s | 15 KBi |
#14 |
Correcto
|
0.177 s | 16 KBi |
#15 |
Correcto
|
0.226 s | 14 KBi |
#16 |
Correcto
|
0.273 s | 14 KBi |
#17 |
Tiempo límite excedido
|
1.002 s | 63 KBi |
#18 |
Correcto
|
0.908 s | 69 KBi |
#19 |
Correcto
|
0.97 s | 70 KBi |
#20 |
Correcto
|
0.902 s | 65 KBi |
#21 |
Correcto
|
0.85 s | 60 KBi |
#22 |
Tiempo límite excedido
|
1.047 s | 66 KBi |
#23 |
Correcto
|
0.872 s | 60 KBi |
#24 |
Correcto
|
0.704 s | 56 KBi |
import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Long sum, smallest, best; sum = 0L; smallest = 0L; best = Long.MIN_VALUE; for (int j = 0; j < n; j++) { sum += sc.nextLong(); best = Math.max(best, sum - smallest); smallest = Math.min(smallest, sum); } sc.close(); System.out.println(best); } }