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

Envío 4606

Problema 0x25 - Suma de un subarreglo grande

  • Autor: 7yrionLannister
  • Fecha: 2021-08-01 19:48:45 UTC (Hace más de 2 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.NumberFormatException: For input string: "0 1"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.073 s 14 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "0 0"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.079 s 25 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "0 0"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.069 s 12 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "3 4"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.066 s 17 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "3 7"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.075 s 11 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "5 43"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.069 s 20 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "12 99"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.074 s 17 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "51 9988"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.125 s 14 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "147 49896"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.219 s 20 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "92 49866"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.212 s 20 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "10 49914"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.256 s 19 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "89 49944"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.22 s 21 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "46360 46362"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.216 s 20 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: For input string: "7348 32348"
	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
	at java.base/java.lang.Integer.parseInt(Integer.java:658)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at Main.main(Main.java:19)
0.225 s 17 KBi
Puntos totales: 0 / 100

Código

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(s.readLine());
        String[] numsS = s.readLine().split(" ");
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = Integer.parseInt(numsS[i]);
        }
        int queries = Integer.parseInt(s.readLine());
        for (int i = 0; i < queries; i++) {
            int start = Integer.parseInt(s.readLine());
            int end = Integer.parseInt(s.readLine());
            int sum = 0;
            for (int j = start; j <= end; j++) {
                sum += nums[j];
            }
            bw.write(sum + "\n");
        }
    }
}