#C3245. Count Elements Greater than Maximum of Second Array

    ID: 46651 Type: Default 1000ms 256MiB

Count Elements Greater than Maximum of Second Array

Count Elements Greater than Maximum of Second Array

You are given two lists of integers, arr1 and arr2. Your task is to count the number of elements in arr1 that are strictly greater than the maximum element of arr2. If either of the lists is empty, the result should be 0.

In other words, let \( M = \max(arr2) \) (if arr2 is not empty), then you need to compute:

\[ \text{result} = \sum_{x \in arr1} [x > M] \quad \text{, with the convention that if } arr1 \text{ or } arr2 \text{ is empty, result} = 0. \]

Note: The notation \([x > M]\) represents the indicator function which is 1 if x > M is true, and 0 otherwise.

inputFormat

The input is read from standard input and has the following format:

  1. An integer n representing the number of elements in the first list arr1.
  2. A line containing n space-separated integers representing the elements of arr1. If n is 0, this line may be empty.
  3. An integer m representing the number of elements in the second list arr2.
  4. A line containing m space-separated integers representing the elements of arr2. If m is 0, this line may be empty.

outputFormat

The output is a single integer printed to standard output, which represents the number of elements in arr1 that are greater than the maximum element of arr2. If either array is empty, output 0.

## sample
4
5 3 9 7
3
6 4 8
1