← Home
```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)
}
```