Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.096 s | 13 KBi |
#2 |
Correcto
|
0.092 s | 13 KBi |
#3 |
Correcto
|
0.087 s | 13 KBi |
#4 |
Correcto
|
0.094 s | 13 KBi |
#5 |
Correcto
|
0.069 s | 18 KBi |
#6 |
Correcto
|
0.084 s | 13 KBi |
#7 |
Correcto
|
0.091 s | 13 KBi |
#8 |
Correcto
|
0.087 s | 17 KBi |
#9 |
Correcto
|
0.096 s | 13 KBi |
#10 |
Correcto
|
0.07 s | 23 KBi |
#11 |
Correcto
|
0.095 s | 13 KBi |
#12 |
Correcto
|
0.093 s | 13 KBi |
#13 |
Correcto
|
0.086 s | 14 KBi |
#14 |
Correcto
|
0.096 s | 13 KBi |
#15 |
Correcto
|
0.109 s | 19 KBi |
#16 |
Correcto
|
0.116 s | 14 KBi |
#17 |
Correcto
|
0.306 s | 21 KBi |
#18 |
Correcto
|
0.343 s | 22 KBi |
#19 |
Correcto
|
0.379 s | 30 KBi |
#20 |
Correcto
|
0.412 s | 27 KBi |
#21 |
Correcto
|
0.353 s | 27 KBi |
#22 |
Correcto
|
0.433 s | 30 KBi |
#23 |
Correcto
|
0.298 s | 21 KBi |
#24 |
Correcto
|
0.336 s | 25 KBi |
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main{ public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; try { int n = Integer.parseInt(br.readLine()); Long sum, smallest, best; sum = 0L; smallest = 0L; best = Long.MIN_VALUE; st = new StringTokenizer(br.readLine()); for (int j = 0; j < n; j++) { sum += Long.parseLong(st.nextToken()); best = Math.max(best, sum - smallest); smallest = Math.min(smallest, sum); } br.close(); System.out.println(best); } catch (Exception e) { } finally { } } }