Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 6 KBi |
#2 |
Correcto
|
0.004 s | 5 KBi |
#3 |
Correcto
|
0.004 s | 8 KBi |
#4 |
Correcto
|
0.005 s | 5 KBi |
#5 |
Correcto
|
0.004 s | 8 KBi |
#6 |
Correcto
|
0.004 s | 6 KBi |
#7 |
Correcto
|
0.005 s | 7 KBi |
#8 |
Correcto
|
0.206 s | 9 KBi |
#9 |
Tiempo límite excedido
|
1.049 s | 13 KBi |
#10 |
Tiempo límite excedido
|
1.055 s | 13 KBi |
#11 |
Tiempo límite excedido
|
1.027 s | 11 KBi |
#12 |
Tiempo límite excedido
|
1.09 s | 15 KBi |
#13 |
Tiempo límite excedido
|
1.05 s | 10 KBi |
#14 |
Tiempo límite excedido
|
1.075 s | 15 KBi |
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) type SubArrayData struct { P int64 Q int64 } func main() { reader := bufio.NewReader(os.Stdin) n, _ := reader.ReadString('\n') n = strings.ReplaceAll(n, "\n", "") nArray, _ := reader.ReadString('\n') nArray = strings.ReplaceAll(nArray, "\n", "") numbers := strings.Split(nArray, " ") c, _ := reader.ReadString('\n') c = strings.ReplaceAll(c, "\n", "") cNumber, _ := strconv.ParseInt(c, 10, 64) numbersCases := make([]SubArrayData, 0) numbersSolution := make([]int64, 0) 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) numbersCases = append(numbersCases, SubArrayData{P: p, Q: q}) numbersSolution = append(numbersSolution, 0) } for i := 0; i < len(numbers); i++ { number, _ := strconv.ParseInt(numbers[i], 10, 64) for j := 0; j < len(numbersCases); j++ { subArray := numbersCases[j] if i >= int(subArray.P) && i <= int(subArray.Q) { numbersSolution[j] = numbersSolution[j] + number } } } for i := 0; i < len(numbersSolution); i++ { fmt.Println(numbersSolution[i]) } }