Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.002 s | 3 KBi |
#2 |
Correcto
|
0.003 s | 3 KBi |
#3 |
Correcto
|
0.004 s | 4 KBi |
#4 |
Correcto
|
0.002 s | 3 KBi |
#5 |
Correcto
|
0.003 s | 3 KBi |
#6 |
Correcto
|
0.002 s | 3 KBi |
#7 |
Correcto
|
0.002 s | 4 KBi |
#8 |
Correcto
|
0.003 s | 4 KBi |
#9 |
Correcto
|
0.002 s | 4 KBi |
#10 |
Correcto
|
0.004 s | 4 KBi |
#11 |
Incorrecto
|
0.002 s | 4 KBi |
#12 |
Correcto
|
0.003 s | 4 KBi |
#13 |
Incorrecto
|
0.002 s | 3 KBi |
#14 |
Correcto
|
0.013 s | 4 KBi |
#15 |
Incorrecto
|
0.006 s | 23 KBi |
#16 |
Correcto
|
0.002 s | 4 KBi |
#17 |
Incorrecto
|
0.004 s | 4 KBi |
#18 |
Correcto
|
0.002 s | 4 KBi |
#19 |
Correcto
|
0.002 s | 4 KBi |
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) type Value struct { IsActive bool Sum int64 } func main() { reader := bufio.NewReader(os.Stdin) reader.ReadString('\n') numbers, _ := reader.ReadString('\n') numbers = strings.ReplaceAll(numbers, "\n", "") numbersSeparate := strings.Split(numbers, " ") heights := make(map[int64]Value) var maxValue int64 = 0 for _, value := range numbersSeparate { valueInt, _ := strconv.ParseInt(value, 10, 64) if _, ok := heights[valueInt]; !ok { heights[valueInt] = Value{ IsActive: true, Sum: 0, } } for key, val := range heights { if heights[key].IsActive { if key > valueInt { val.IsActive = false } else { val.Sum += key } heights[key] = val } if val.Sum > maxValue { maxValue = val.Sum } } } fmt.Println(maxValue) }