Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.004 s | 4 KBi |
#2 |
Correcto
|
0.003 s | 4 KBi |
#3 |
Correcto
|
0.005 s | 5 KBi |
#4 |
Correcto
|
0.004 s | 16 KBi |
#5 |
Correcto
|
0.004 s | 3 KBi |
#6 |
Correcto
|
0.004 s | 4 KBi |
#7 |
Correcto
|
0.004 s | 4 KBi |
#8 |
Correcto
|
0.005 s | 4 KBi |
#9 |
Correcto
|
0.005 s | 4 KBi |
#10 |
Correcto
|
0.004 s | 4 KBi |
#11 |
Correcto
|
0.004 s | 4 KBi |
#12 |
Correcto
|
0.004 s | 5 KBi |
#13 |
Correcto
|
0.003 s | 3 KBi |
#14 |
Correcto
|
0.059 s | 16 KBi |
#15 |
Correcto
|
0.081 s | 17 KBi |
#16 |
Correcto
|
0.081 s | 17 KBi |
#17 |
Correcto
|
0.068 s | 17 KBi |
#18 |
Correcto
|
0.055 s | 18 KBi |
#19 |
Correcto
|
0.061 s | 18 KBi |
#20 |
Correcto
|
0.084 s | 19 KBi |
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { reader := bufio.NewReader(os.Stdin) number, _ := reader.ReadString('\n') number = strings.ReplaceAll(number, "\n", "") numberArrayS, _ := reader.ReadString('\n') numberArrayS = strings.ReplaceAll(numberArrayS, "\n", "") numbersArray := strings.Split(numberArrayS, " ") index := 0 result := -1 var sumTotal int64 = 0 var sumLeft int64 = 0 for i := 0; i < len(numbersArray); i++ { numberIndex, _ := strconv.ParseInt(numbersArray[i], 10, 64) sumTotal += numberIndex } for result == -1 && index < len(numbersArray)-1 { numberIndex, _ := strconv.ParseInt(numbersArray[index], 10, 64) sumLeft += numberIndex sumTotal -= numberIndex if sumLeft > 0 && sumTotal < 0 { result = index + 1 } index++ } if result == -1 { fmt.Println("Impossible") } else { fmt.Println(result) } }