#C8980. Maximum Subsequence Score
Maximum Subsequence Score
Maximum Subsequence Score
You are given two arrays of integers, a
and b
, each containing n elements. A non-empty subsequence of an array is a sequence that can be derived by deleting zero or more elements without changing the order of the remaining elements. Note that even a single element is considered a valid subsequence.
The score for a pair of non-empty subsequences is defined as the maximum absolute difference between any element from the chosen subsequence of a
and any element from the chosen subsequence of b
. Formally, since any single element qualifies as a subsequence, the maximum score over all such pairs is given by:
Your task is to compute and output this maximum score.
inputFormat
The input is given in the following format:
- The first line contains an integer n representing the number of elements in each array.
- The second line contains n space-separated integers, representing the array
a
. - The third line contains n space-separated integers, representing the array
b
.
outputFormat
Output a single integer, which is the maximum score computed as the maximum absolute difference between any element of a
and any element of b
.
3
1 2 3
4 5 6
5