P8321 "JROI-4" Shenyang Avenue 2

Description

Given two sequences $A, B$ of length $n$, satisfying: * $\forall 1\le i

Input Format

The first line contains an integer $n$. The second line contains $n$ integers, denoting $A_i$. The third line contains $n$ integers, denoting $B_i$.

Output Format

Output one line containing one integer, the answer.

Explanation/Hint

**This problem uses bundled testdata.** | Subtask ID | Score | Special Constraints | | :-----------: | :---:| :-----------: | | 1 | 5 | $1\le n\le 8$ | | 2 | 35 | $1\le n\le 50$ | | 3 | 20 | $A_n\ge \max\limits_{i=1}^n(B_i)$ | | 4 | 40 | None | For $100\%$ of the data, $1\le n\le 5000$, $1\le A_i,B_i\le 10^9$. Translated by ChatGPT 5