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

Envío 1389

Problema 0x25 - Suma de un subarreglo grande

  • Autor: judavid.arias
  • Fecha: 2020-10-24 21:10:34 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.122 s 11 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.121 s 12 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.118 s 12 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.112 s 12 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.092 s 10 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.116 s 12 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.095 s 11 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.094 s 11 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.122 s 12 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.08 s 12 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.105 s 12 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.108 s 12 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.123 s 12 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Error: Could not find or load main class Main
Caused by: java.lang.NoClassDefFoundError: com/company/Main (wrong name: Main)
0.099 s 10 KBi
Puntos totales: 0 / 100

Código

package com.company;

import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int []array = new int[N];

        int []sums = new int[N];
        int sum = 0;
        for(int i = 0;i<N;i++){
            array[i] = sc.nextInt();
            sum += array[i];
            sums[i] = sum;
        }

        int c = sc.nextInt();
        for(int i = 0;i<c;i++){
            int p = sc.nextInt();
            int q = sc.nextInt();
            int result = sums[q]-sums[p]+array[p];
            System.out.println(result);
        }




    }

}