Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.003 s | 3 KBi |
#2 |
Correcto
|
0.004 s | 3 KBi |
#3 |
Correcto
|
0.004 s | 3 KBi |
#4 |
Correcto
|
0.004 s | 4 KBi |
#5 |
Correcto
|
0.004 s | 4 KBi |
#6 |
Correcto
|
0.004 s | 4 KBi |
#7 |
Correcto
|
0.005 s | 3 KBi |
#8 |
Correcto
|
0.127 s | 5 KBi |
#9 |
Tiempo límite excedido
|
1.051 s | 9 KBi |
#10 |
Tiempo límite excedido
|
1.088 s | 8 KBi |
#11 |
Tiempo límite excedido
|
1.089 s | 8 KBi |
#12 |
Tiempo límite excedido
|
1.088 s | 8 KBi |
#13 |
Correcto
|
0.201 s | 9 KBi |
#14 |
Tiempo límite excedido
|
1.039 s | 9 KBi |
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) type SubArrayData struct { P int64 Q int64 } func main() { reader := bufio.NewReader(os.Stdin) reader.ReadString('\n') nArray, _ := reader.ReadString('\n') nArray = strings.ReplaceAll(nArray, "\n", "") numbers := strings.Split(nArray, " ") numberArray := make([]int64, 0) for i := 0; i < len(numbers); i++ { number, _ := strconv.ParseInt(numbers[i], 10, 64) numberArray = append(numberArray, number) } c, _ := reader.ReadString('\n') c = strings.ReplaceAll(c, "\n", "") cNumber, _ := strconv.ParseInt(c, 10, 64) for i := 0; i < int(cNumber); i++ { caseLine, _ := reader.ReadString('\n') caseLine = strings.ReplaceAll(caseLine, "\n", "") numbersCase := strings.Split(caseLine, " ") p, _ := strconv.ParseInt(numbersCase[0], 10, 64) q, _ := strconv.ParseInt(numbersCase[1], 10, 64) numbersTwo := numberArray[p : q+1] var sum int64 = 0 for _, v := range numbersTwo { sum += v } fmt.Println(sum) } }