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

Envío 4244

Problema 0x25 - Suma de un subarreglo grande

  • Autor: andres0608
  • Fecha: 2021-05-30 03:18:19 UTC (Hace casi 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.126 s 12 KBi
#2
Incorrecto
0.231 s 24 KBi
#3
Incorrecto
0.165 s 12 KBi
#4
Incorrecto
0.166 s 12 KBi
#5
Incorrecto
0.143 s 12 KBi
#6
Incorrecto
0.178 s 16 KBi
#7
Incorrecto
0.346 s 19 KBi
#8
Tiempo límite excedido
1.029 s 97 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 137
run: line 1:     3 Killed                  /usr/local/openjdk13/bin/java Main
0.921 s 125 KBi
#10
Tiempo límite excedido
1.025 s 108 KBi
#11
Tiempo límite excedido
1.07 s 63 KBi
#12
Tiempo límite excedido
1.021 s 90 KBi
#13
Tiempo límite excedido
1.102 s 54 KBi
#14
Tiempo límite excedido
1.095 s 123 KBi
Puntos totales: 0 / 100

Código

import java.util.*;
public class Main {

     public static void main(String[] args) throws Exception {
		 
		 String  numero1, numero2,numero3,valor,numero4;
		 Scanner numeros = new Scanner(System.in);
		 numero1 = numeros.nextLine();
		 numero2="";
		 numero2 += numeros.nextLine();
		 numero3= numeros.nextLine();
		 String[] numbers = numero2.split(" ");
		 double result;
		 for(int i=0;i < Integer.parseInt(numero3);i++) {
			 numero4="";
			 numero4+= numeros.nextLine();
			 result = contar(numbers, numero4);
			 System.out.println(result);
		 }
		 numeros.close();  
		 
	 }
	 
	 
	 public static double  contar(String[] v, String c) {
		 String[] valores = c.split(" ");
		 double suma= 0;
		 for(int i= Integer.parseInt(valores[0]); i <= Integer.parseInt(valores[1]); i++) {
			 suma += Double.parseDouble(v[i]);
		 }
		 return suma;
	 }

}