cswork / OA打开练习工作台

VisaOA #16

Longest Selectable Non-Decreasing Subarray

估计中等可在线判题

考点(AI 标注)状态机

A and B have equal length; for each position of a contiguous subarray, choose exactly one of A[i] or B[i]. Find the longest length that can form a non-decreasing sequence.

输入格式

n (1≤n≤200000), then two lines with arrays A and B, whose elements have absolute value ≤10⁹; the ranges are site-added.

输出格式

Output the maximum length.

样例 1

输入:

4
1 3 5 4
2 2 6 7

输出:

4

样例 2

输入:

3
5 4 3
1 2 3

输出:

3

样例 3

输入:

1
3
1

输出:

1