Suitable Edit for LIS

AtCoder
IDabc360_g
Time2000ms
Memory256MB
Difficulty
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$ [samples]
Samples
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
API Response (JSON)
{
  "problem": {
    "name": "Suitable Edit for LIS",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc360_g"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given an integer sequence $A$ of length $N$. Takahashi will perform the following operation exactly once:\n\n*   Choose an integer $x$ between $1$ and $N$, inclusive, and an arbitrary integer $y...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments