← Home
For problem statement at 0-999/300-399/360-369/364/problemB.txt this is a correct solution, but verifier at 0-999/300-399/360-369/364/verifierB.go ends with case 10 failed: expected 6 2 got 6 3
input:
2 3
2 4
exit status 1 can you fix the verifier? ```go
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n, d int
	fmt.Fscan(in, &n, &d)
	c := make([]int, n)
	maxSum := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &c[i])
		maxSum += c[i]
	}

	sort.Ints(c)

	reachable := make([]bool, maxSum+1)
	reachable[0] = true
	for _, val := range c {
		for s := maxSum; s >= val; s-- {
			if reachable[s-val] {
				reachable[s] = true
			}
		}
	}

	current := 0
	days := 0
	for {
		next := current
		upper := current + d
		if upper > maxSum {
			upper = maxSum
		}
		for s := upper; s > current; s-- {
			if reachable[s] {
				next = s
				break
			}
		}
		if next == current {
			break
		}
		current = next
		days++
	}

	fmt.Fprintln(out, current, days)
}
```