█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 2241

Problema 0x94 - Subarreglo de máxima suma

  • Autor: aebernalmunoz
  • Fecha: 2020-12-07 01:20:26 UTC (Hace alrededor de 4 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.171 s 16 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.179 s 15 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.179 s 16 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.186 s 16 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.189 s 16 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.16 s 16 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.19 s 16 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.195 s 16 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.173 s 16 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.18 s 16 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.178 s 16 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.191 s 12 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.209 s 16 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.177 s 15 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.183 s 16 KBi
#16
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.149 s 16 KBi
#17
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.188 s 12 KBi
#18
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.187 s 12 KBi
#19
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.174 s 12 KBi
#20
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.178 s 12 KBi
#21
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.167 s 12 KBi
#22
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.18 s 12 KBi
#23
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.178 s 12 KBi
#24
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.IllegalStateException: Scanner closed
	at java.base/java.util.Scanner.ensureOpen(Scanner.java:1150)
	at java.base/java.util.Scanner.next(Scanner.java:1573)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2373)
	at java.base/java.util.Scanner.nextLong(Scanner.java:2328)
	at Main.main(Main.java:14)
0.173 s 16 KBi
Puntos totales: 0 / 100

Código

import java.util.Scanner;

class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		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);

	}

}