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

Envío 6573

Problema 0x25 - Suma de un subarreglo grande

  • Autor: carrillodev
  • Fecha: 2022-08-08 01:07:41 UTC (Hace más de 1 año)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.004 s 3 KBi
#2
Correcto
0.004 s 1 KBi
#3
Correcto
0.004 s 1 KBi
#4
Correcto
0.005 s 1 KBi
#5
Correcto
0.006 s 1 KBi
#6
Correcto
0.004 s 4 KBi
#7
Correcto
0.005 s 1 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.007 s 1 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.018 s 1 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.015 s 2 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.02 s 2 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.013 s 1 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.02 s 1 KBi
#14
Error en tiempo de ejecución (NZEC)
Exited with error status 139
run: line 1:     3 Segmentation fault      (core dumped) ./a.out
0.012 s 1 KBi
Puntos totales: 50 / 100

Código

#include <iostream>
#include <climits>
using namespace std;

int main() {
    int n; cin>>n;
    int arr[n];
    for(int i = 0; i < n; i++) {
        cin>>arr[i];
    }

    int sums[n][n];
    for(int i = 0; i < n; i++) {
        int currSum = 0;
        for(int j = i; j < n; j++) {
            currSum += arr[j];
            sums[i][j] = currSum;
        }
    }

    int c; cin>>c;
    int results[c];
    for(int i = 0; i < c; i++) {
        int p, q; cin>>p>>q;
        results[i] = sums[p][q];
    }
    for(int i = 0; i < c; i++) {
        cout<<results[i]<<endl;
    }
    return 0;
}