Alice and Bob are playing an array game. Initially, each of them has an array of length . Alice's array is
and Bob's array is
, where all
and
are positive integers.
Alice may perform any number of operations (including zero). In a single operation, she chooses a contiguous interval (
) and replaces every element in that interval by the maximum value over that interval. Formally, she computes
, and then for every
(
) sets
.
After Alice finishes all her operations, she compares her final array to Bob's array
. She scores one point for each index
where
. Compute the maximum number of points Alice can get by choosing her operations optimally.
Input Specification
The first line contains an integer (
), the length of the arrays.
The second line contains integers
, (
), indicating Alice's array.
The third line contains integers
, (
), indicating Bob's array.
Output Specification
Print a single integer, the maximum number of points Alice can achieve.
Constraints
Subtask | Points | Additional constraints |
---|---|---|
All | ||
No additional constraints |
Sample Input
4
10 2 9 2
10 9 10 9
Sample Output
3
Explanation for Sample
Alice can choose the interval and change the array to
, then she can get
points. There is no way to get more points.
Comments