█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 5050

Problema 0xf2 - Partir un arreglo grande en 2

  • Autor: cams2692
  • Fecha: 2021-10-08 14:42:35 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
0.004 s 10 KBi
#2
Correcto
0.004 s 8 KBi
#3
Incorrecto
0.004 s 26 KBi
#4
Incorrecto
0.005 s 6 KBi
#5
Correcto
0.003 s 5 KBi
#6
Tiempo límite excedido
1.056 s 24 KBi
#7
Tiempo límite excedido
1.068 s 4 KBi
#8
Tiempo límite excedido
1.078 s 4 KBi
#9
Incorrecto
0.004 s 9 KBi
#10
Tiempo límite excedido
1.096 s 7 KBi
#11
Tiempo límite excedido
1.048 s 9 KBi
#12
Tiempo límite excedido
1.09 s 27 KBi
#13
Incorrecto
0.004 s 32 KBi
#14
Tiempo límite excedido
1.085 s 17 KBi
#15
Correcto
0.063 s 17 KBi
#16
Tiempo límite excedido
1.022 s 17 KBi
#17
Correcto
0.099 s 17 KBi
#18
Tiempo límite excedido
1.044 s 17 KBi
#19
Tiempo límite excedido
1.075 s 18 KBi
#20
Tiempo límite excedido
1.065 s 21 KBi
Puntos totales: 20 / 100

Código

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 := len(numbersArray) - 1
	result := -1

	var sumTotal int64 = 0
	var sumLeft int64 = 0

	for i := 0; i < len(numbersArray); i++ {
		numberIndex, _ := strconv.ParseInt(numbersArray[index], 10, 64)
		sumTotal += numberIndex
	}

	for result == -1 && index > 0 {
		numberIndex, _ := strconv.ParseInt(numbersArray[index], 10, 64)
		sumLeft += numberIndex
		sumTotal -= numberIndex
		if sumLeft < 0 && sumTotal > 0 {
			result = index
		}

	}
	if result == -1 {
		fmt.Println("Impossible")
	} else {
		fmt.Println(result)
	}

}