Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.171 s | 12 KBi |
#2 |
Correcto
|
0.169 s | 13 KBi |
#3 |
Correcto
|
0.181 s | 12 KBi |
#4 |
Correcto
|
0.187 s | 15 KBi |
#5 |
Correcto
|
0.182 s | 13 KBi |
#6 |
Correcto
|
0.181 s | 16 KBi |
#7 |
Correcto
|
0.177 s | 12 KBi |
#8 |
Correcto
|
0.183 s | 16 KBi |
#9 |
Correcto
|
0.181 s | 16 KBi |
#10 |
Correcto
|
0.164 s | 16 KBi |
#11 |
Correcto
|
0.184 s | 16 KBi |
#12 |
Correcto
|
0.182 s | 15 KBi |
#13 |
Correcto
|
0.202 s | 16 KBi |
#14 |
Correcto
|
0.172 s | 16 KBi |
#15 |
Correcto
|
0.267 s | 18 KBi |
#16 |
Correcto
|
0.29 s | 19 KBi |
#17 |
Tiempo límite excedido
|
1.003 s | 67 KBi |
#18 |
Tiempo límite excedido
|
1.011 s | 73 KBi |
#19 |
Tiempo límite excedido
|
1.069 s | 72 KBi |
#20 |
Tiempo límite excedido
|
1.008 s | 57 KBi |
#21 |
Correcto
|
0.93 s | 55 KBi |
#22 |
Tiempo límite excedido
|
1.039 s | 67 KBi |
#23 |
Correcto
|
0.724 s | 56 KBi |
#24 |
Correcto
|
0.968 s | 63 KBi |
import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Integer ar[] = new Integer[n]; for (int i = 0; i < ar.length; i++) { ar[i] = sc.nextInt(); } sc.close(); Long sum, smallest, best; sum = smallest = 0L; best = (long) ar[0]; for (int j = 0; j < ar.length; j++) { sum += ar[j]; best = Math.max(best, sum - smallest); smallest = Math.min(smallest, sum); } System.out.println(best); } }