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

Envío 3150

Problema 0x25 - Suma de un subarreglo grande

  • Autor: militoromero10
  • Fecha: 2021-02-23 23:13:21 UTC (Hace alrededor de 3 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.094 s 18 KBi
#2
Correcto
0.078 s 14 KBi
#3
Correcto
0.097 s 18 KBi
#4
Correcto
0.08 s 15 KBi
#5
Correcto
0.092 s 13 KBi
#6
Correcto
0.102 s 21 KBi
#7
Correcto
0.1 s 14 KBi
#8
Correcto
0.943 s 24 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"50000" Radix:10
	at java.base/java.lang.Short.parseShort(Short.java:123)
	at java.base/java.lang.Short.parseShort(Short.java:147)
	at Main.main(Main.java:9)
0.086 s 13 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"50000" Radix:10
	at java.base/java.lang.Short.parseShort(Short.java:123)
	at java.base/java.lang.Short.parseShort(Short.java:147)
	at Main.main(Main.java:9)
0.084 s 13 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"50000" Radix:10
	at java.base/java.lang.Short.parseShort(Short.java:123)
	at java.base/java.lang.Short.parseShort(Short.java:147)
	at Main.main(Main.java:9)
0.083 s 14 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"50000" Radix:10
	at java.base/java.lang.Short.parseShort(Short.java:123)
	at java.base/java.lang.Short.parseShort(Short.java:147)
	at Main.main(Main.java:9)
0.097 s 16 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"50000" Radix:10
	at java.base/java.lang.Short.parseShort(Short.java:123)
	at java.base/java.lang.Short.parseShort(Short.java:147)
	at Main.main(Main.java:9)
0.08 s 14 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value:"50000" Radix:10
	at java.base/java.lang.Short.parseShort(Short.java:123)
	at java.base/java.lang.Short.parseShort(Short.java:147)
	at Main.main(Main.java:9)
0.088 s 13 KBi
Puntos totales: 58 / 100

Código

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Throwable {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        for(String ln; (ln = in.readLine())!= null;){
            short N = Short.parseShort(ln);
            StringTokenizer st = new StringTokenizer(in.readLine());
            StringBuilder sb = new StringBuilder();
            short[] values = new short[N];
            for(int i=0; i<N; i++) values[i] = Short.parseShort(st.nextToken());

            short Q = Short.parseShort(in.readLine());
            while(Q-->0){
                st = new StringTokenizer(in.readLine());
                short p = Short.parseShort(st.nextToken());
                short q = Short.parseShort(st.nextToken());
                int total = 0;
                for(;p<=q;p++) total+= values[p];
                sb.append(total).append("\n");
            }
            System.out.print(new String(sb).trim());
        }
    }
}