package main import ( "bufio" "fmt" "os" "sort" "strconv" ) func appendSorted(a []int, b int) []int { i := sort.Search(len(a), func(i int) bool { return a[i] >= b }) a = append(a, 0) for j := len(a) - 1; j > i; j-- { a[j] = a[j-1] } a[i] = b return a } func main() { defer flush() N := readInt() a := make([]int, N) for i := 0; i < N; i++ { a[i] = readInt() } b := make([]int, N) for i := 0; i < N; i++ { b[i] = readInt() } sort.Ints(a) t := make([]int, 0, N) result := 0 for i := 0; i < N; i++ { t = appendSorted(t, b[i]) result += sort.Search(len(t), func(j int) bool { return t[j] >= a[i] }) } println(result) } const ( ioBufferSize = 1 * 1024 * 1024 // 1 MB ) var stdinScanner = func() *bufio.Scanner { result := bufio.NewScanner(os.Stdin) result.Buffer(make([]byte, ioBufferSize), ioBufferSize) result.Split(bufio.ScanWords) return result }() func readString() string { stdinScanner.Scan() return stdinScanner.Text() } func readInt() int { result, err := strconv.Atoi(readString()) if err != nil { panic(err) } return result } var stdoutWriter = bufio.NewWriter(os.Stdout) func flush() { stdoutWriter.Flush() } func println(args ...interface{}) (int, error) { return fmt.Fprintln(stdoutWriter, args...) }