← Home
For problem statement at 0-999/0-99/10-19/16/problemD.txt this is a correct solution, but verifier at 0-999/0-99/10-19/16/verifierD.go ends with case 1 failed: runtime error: exit status 2
panic: runtime error: slice bounds out of range [:-1]

goroutine 1 [running]:
main.main()
	/tmp/build-187016858/solution.go:21 +0x478


exit status 1 can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	minutes := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		line, _ := reader.ReadString('\n')
		line = strings.TrimSpace(line)
		start := strings.Index(line, "[")
		end := strings.Index(line, "]")
		time_str := line[start+1 : end]
		hh, _ := strconv.Atoi(time_str[0:2])
		mm, _ := strconv.Atoi(time_str[3:5])
		ampm := time_str[6:]
		hh24 := hh
		if ampm == "a.m." {
			if hh == 12 {
				hh24 = 0
			}
		} else if ampm == "p.m." {
			if hh != 12 {
				hh24 += 12
			}
		}
		minutes[i] = hh24*60 + mm
	}
	days := 0
	pos := 0
	for pos < n {
		days++
		var freq [1440]int
		last_min := -1
		maxend := pos - 1
		for j := pos; j < n; j++ {
			cur := minutes[j]
			if last_min != -1 && cur < last_min {
				break
			}
			freq[cur]++
			if freq[cur] > 10 {
				freq[cur]--
				break
			}
			last_min = cur
			maxend = j
		}
		pos = maxend + 1
	}
	fmt.Println(days)
}
```