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

Envío 5830

Problema 0x25 - Suma de un subarreglo grande

  • Autor: Sugaaron
  • Fecha: 2022-03-04 16:33:21 UTC (Hace alrededor de 2 años)
Caso # Resultado Tiempo Memoria
#1
Correcto
0.041 s 14 KBi
#2
Correcto
0.036 s 14 KBi
#3
Correcto
0.036 s 14 KBi
#4
Correcto
0.07 s 10 KBi
#5
Correcto
0.08 s 10 KBi
#6
Correcto
0.069 s 29 KBi
#7
Correcto
0.047 s 14 KBi
#8
Correcto
0.821 s 43 KBi
#9
Tiempo límite excedido
1.112 s 34 KBi
#10
Tiempo límite excedido
1.061 s 20 KBi
#11
Tiempo límite excedido
1.014 s 27 KBi
#12
Tiempo límite excedido
1.056 s 21 KBi
#13
Correcto
0.559 s 58 KBi
#14
Tiempo límite excedido
1.054 s 30 KBi
Puntos totales: 65 / 100

Código

import java.io.*;
import java.util.StringTokenizer;
import java.util.*;

class Main
{
    public static void main(String[] args) throws IOException{
        List<Integer> arr = new ArrayList<Integer>();
        List<Integer> res = new ArrayList<Integer>();
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        st=new StringTokenizer(br.readLine());
        st=new StringTokenizer(br.readLine());
        while(st.hasMoreTokens()){
            arr.add(Integer.parseInt(st.nextToken()));
        }
        st=new StringTokenizer(br.readLine());
        int x = Integer.parseInt(st.nextToken());
        int cont = 0;
        while(x>0){
            st=new StringTokenizer(br.readLine());
            int p = Integer.parseInt(st.nextToken());
            int q = Integer.parseInt(st.nextToken());
            for(int i=p;i<=q;i++){
                cont+=arr.get(i);
            }
            res.add(cont);
            cont = 0;
            x--;
        }
        for(int i : res){
            System.out.println(i);
        }
    }
}