← Home
```go
package main

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

// Carton represents a milk carton in the shop with its value and original index
type Carton struct {
	val int
	id  int
}

// ByValDesc implements sort.Interface to sort Cartons by value in descending order
type ByValDesc []Carton

func (a ByValDesc) Len() int           { return len(a) }
func (a ByValDesc) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByValDesc) Less(i, j int) bool { return a[i].val > a[j].val }

func main() {
	// Configure fast I/O
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	// Helper function to read the next integer
	readInt := func() int {
		scanner.Scan()
		val, _ := strconv.Atoi(scanner.Text())
		return val
	}

	// Read n, m, k
	if !scanner.Scan() {
		return
	}
	n, _ := strconv.Atoi(scanner.Text())
	m := readInt()
	k := readInt()

	// Read fridge cartons
	fridge := make([]int, n)
	for i := 0; i < n; i++ {
		fridge[i] = readInt()
	}

	// Read shop cartons
	shop := make([]Carton, m)
	for i := 0; i < m; i++ {
		shop[i] = Carton{val: readInt(), id: i + 1}
	}

	// Sort fridge cartons in ascending order to simulate earliest deadlines first
	sort.Ints(fridge)

	// Check if Olya can drink the cartons already in the fridge
	for i, f := range fridge {
		// The i-th carton (0-indexed) will be drunk on day i/k.
		// Its expiration date f must be >= i/k.
		if f < i/k {
			fmt.Fprintln(writer, -1)
			return
		}
	}

	// Sort shop cartons in descending order to prioritize buying cartons with best expiration dates
	sort.Sort(ByValDesc(shop))

	// Binary search for the maximum number of cartons x Olya can buy
	// Range: [0, m]
	low, high := 0, m
	ans := 0

	for low <= high {
		mid := (low + high) / 2
		
		// Check if it is possible to drink all fridge cartons + top 'mid' shop cartons
		possible := true
		
		fIdx := 0
		sIdx := mid - 1 // We want to merge shop[0...mid-1]. Since shop is descending, start from end to simulate ascending merge.
		
		total := n + mid
		
		// Iterate through all cartons in the order they would be drunk (sorted by expiry)
		for i := 0; i < total; i++ {
			var curr int
			
			// Select the smallest available expiration date from fridge or selected shop cartons
			if fIdx < n && sIdx >= 0 {
				if fridge[fIdx] <= shop[sIdx].val {
					curr = fridge[fIdx]
					fIdx++
				} else {
					curr = shop[sIdx].val
					sIdx--
				}
			} else if fIdx < n {
				curr = fridge[fIdx]
				fIdx++
			} else {
				curr = shop[sIdx].val
				sIdx--
			}
			
			// Check if this carton can be drunk on day i/k
			if curr < i/k {
				possible = false
				break
			}
		}

		if possible {
			ans = mid
			low = mid + 1
		} else {
			high = mid - 1
		}
	}

	// Output the result
	fmt.Fprintln(writer, ans)
	if ans > 0 {
		for i := 0; i < ans; i++ {
			if i > 0 {
				fmt.Fprint(writer, " ")
			}
			fmt.Fprint(writer, shop[i].id)
		}
		fmt.Fprintln(writer)
	}
}
```