← Home
For problem statement at 1000-1999/1000-1099/1000-1009/1007/problemA.txt this is a correct solution, but verifier at 1000-1999/1000-1099/1000-1009/1007/verifierA.go ends with All 100 tests passed can you fix the verifier? package main

import (
	"fmt"
	"io"
	"os"
	"sort"
)

func main() {
	data, _ := io.ReadAll(os.Stdin)
	idx := 0
	readInt := func() int {
		for idx < len(data) && (data[idx] < '0' || data[idx] > '9') {
			idx++
		}
		val := 0
		for idx < len(data) && data[idx] >= '0' && data[idx] <= '9' {
			val = val*10 + int(data[idx]-'0')
			idx++
		}
		return val
	}

	n := readInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = readInt()
	}

	sort.Ints(a)

	i, j, ans := 0, 0, 0
	for i < n && j < n {
		if a[j] > a[i] {
			ans++
			i++
			j++
		} else {
			j++
		}
	}

	fmt.Print(ans)
}