#C3245. Count Elements Greater than Maximum of Second Array
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:
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:
- An integer n representing the number of elements in the first list
arr1
. - A line containing n space-separated integers representing the elements of
arr1
. If n is 0, this line may be empty. - An integer m representing the number of elements in the second list
arr2
. - 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
.
4
5 3 9 7
3
6 4 8
1