← Home
For problem statement at 1000-1999/1100-1199/1130-1139/1132/problemB.txt this is a correct solution, but verifier at 1000-1999/1100-1199/1130-1139/1132/verifierB.go ends with All 100 tests passed can you fix the verifier? ```go
package main

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

func main() {
	// Use buffered I/O for efficient reading and writing
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

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

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

	// Read chocolate bar costs and compute total sum
	a := make([]int, n)
	var totalSum int64
	for i := 0; i < n; i++ {
		a[i] = readInt()
		totalSum += int64(a[i])
	}

	// Sort costs in descending order to easily pick the most expensive ones
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	// Read m
	m := readInt()

	// Process each coupon
	for i := 0; i < m; i++ {
		q := readInt()
		// To minimize cost, we want to maximize the discount.
		// The discount is the price of the free bar.
		// If we pick q bars, the cheapest one is free.
		// We should pick the q most expensive bars to maximize the value of the cheapest among them.
		// In the sorted descending array, the q-th most expensive bar is at index q-1.
		discount := int64(a[q-1])
		
		ans := totalSum - discount
		
		if i > 0 {
			writer.WriteByte(' ')
		}
		fmt.Fprint(writer, ans)
	}
	writer.WriteByte('\n')
}
```