AtCoder Beginner Contest 360
G
Suitable Edit for LIS
AtCoder
⌀ 1982
原题
翻译中…

Problem Statement

翻译中…

You are given an integer sequence $A$ of length $N$. Takahashi will perform the following operation exactly once:

翻译中…
  • Choose an integer $x$ between $1$ and $N$, inclusive, and an arbitrary integer $y$. Replace $A_x$ with $y$.
翻译中…

Find the maximum possible length of a longest increasing subsequence (LIS) of $A$ after performing the operation.

翻译中…

What is longest increasing subsequence? A subsequence of a sequence $A$ is a sequence that can be derived from $A$ by extracting some elements without changing the order. A longest increasing subsequence of a sequence $A$ is a longest subsequence of $A$ that is strictly increasing.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $1 \leq A_i \leq 10^9$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \cdots A_N

翻译中…

Output

翻译中…

Print the answer on a single line.

翻译中…

样例

Input #1
4
3 2 2 4
Output #1
3
The length of a LIS of the given sequence $A$ is $2$. For example, if you replace $A_1$ with $1$, the length of a LIS of $A$ becomes $3$, which is the maximum.
Input #2
5
4 5 3 6 7
Output #2
4
题目信息
题号
abc360_g
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。