P26529 [AtCoder] Comparison
提高-
题目描述

Problem Description

Given two integer sequences of length $ N $, $A = (A_1, A_2, \ldots, A_N)$ and of length $ M $, $B = (B_1, B_2, \ldots, B_M)$.

Find the number of pairs of integers $ (i, j) $ that satisfy all of the following conditions:

  • $1 \leq i \leq N$.
  • $1 \leq j \leq M$.
  • $A_i \leq B_j$.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ A_1 $ $ A_2 $ $\cdots$ $ A_N $ $ B_1 $ $ B_2 $ $\cdots$ $ B_M $

Output Format

Output the number of pairs $ (i, j) $ that satisfy $A_i \leq B_j$.

Sample Input and Output

Sample Input #1

5 4
3 8 10 5 5
1 5 4 9

Sample Output #1

8

Sample Input #2

3 5
2000 2000 2000
1 1 1 1 1

Sample Output #2

0

Sample Input #3

1 1
1000
1000

Sample Output #3

1

Sample Input #4

10 10
3 1 4 1 5 9 2 6 5 3
2 7 1 8 2 8 1 8 2 8

Sample Output #4

58

Notes/Hints

Constraints

  • $1 \leq N \leq 100$.
  • $1 \leq M \leq 100$.
  • $1 \leq A_i \leq 2,000$ ($1 \leq i \leq N$).
  • $1 \leq B_j \leq 2,000$ ($1 \leq j \leq M$).

Sample Explanation 1

The $ 8 $ pairs $ (1,2), (1,3), (1,4), (2,4), (4,2), (4,4), (5,2), (5,4) $ satisfy the conditions, so output $ 8 $.

Sample Explanation 2

No pairs $ (i, j) $ satisfy the conditions, so output $ 0 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 4 3 8 10 5 5 1 5 4 9
样例输出
8