Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 7 KBi |
#2 |
Correcto
|
0.005 s | 6 KBi |
#3 |
Correcto
|
0.004 s | 6 KBi |
#4 |
Correcto
|
0.005 s | 5 KBi |
#5 |
Correcto
|
0.004 s | 6 KBi |
#6 |
Correcto
|
0.006 s | 4 KBi |
#7 |
Correcto
|
0.005 s | 6 KBi |
#8 |
Tiempo límite excedido
|
1.018 s | 6 KBi |
#9 |
Tiempo límite excedido
|
1.037 s | 8 KBi |
#10 |
Tiempo límite excedido
|
1.06 s | 9 KBi |
#11 |
Tiempo límite excedido
|
1.044 s | 7 KBi |
#12 |
Tiempo límite excedido
|
1.06 s | 9 KBi |
#13 |
Correcto
|
0.214 s | 11 KBi |
#14 |
Tiempo límite excedido
|
1.058 s | 6 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", "") nNumber, _ := strconv.ParseInt(n, 10, 64) 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) var numberFirst int64 = nNumber - 1 var numberLast 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}) if p < numberFirst { numberFirst = p } if q > numberLast { numberLast = q } numbersSolution = append(numbersSolution, 0) } for numberFirst < numberLast { number, _ := strconv.ParseInt(numbers[numberFirst], 10, 64) number2, _ := strconv.ParseInt(numbers[numberLast], 10, 64) for j := 0; j < len(numbersCases); j++ { subArray := numbersCases[j] if numberFirst >= subArray.P && numberFirst <= subArray.Q { numbersSolution[j] = numbersSolution[j] + number } if numberLast >= subArray.P && numberLast <= subArray.Q && numberFirst < numberLast { numbersSolution[j] = numbersSolution[j] + number2 } } numberFirst++ numberLast-- } for i := 0; i < len(numbersSolution); i++ { fmt.Println(numbersSolution[i]) } }*/ func main() { reader := bufio.NewReader(os.Stdin) reader.ReadString('\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) 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 := numbers[p : q+1] var sum int64 = 0 for _, v := range numbersTwo { number, _ := strconv.ParseInt(v, 10, 64) sum += number } fmt.Println(sum) } }