#abc360g. G - Suitable Edit for LIS
G - Suitable Edit for LIS
Score : points
问题陈述
给定一个长度为 的整数序列 。高桥将执行以下操作恰好一次:
- 选择一个介于 和 之间的整数 ,以及任意整数 。将 替换为 。
执行操作后,找出 的最长递增子序列(LIS)的最大可能长度。
什么是最长递增子序列?
序列 的一个子序列是通过从 中提取一些元素而不改变顺序得到的序列。
序列 的一个最长递增子序列是 的一个最长子序列,且是严格递增的。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given an integer sequence of length . Takahashi will perform the following operation exactly once:
- Choose an integer between and , inclusive, and an arbitrary integer . Replace with .
Find the maximum possible length of a longest increasing subsequence (LIS) of after performing the operation.
What is longest increasing subsequence?
A subsequence of a sequence is a sequence that can be derived from by extracting some elements without changing the order.
A longest increasing subsequence of a sequence is a longest subsequence of that is strictly increasing.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the answer on a single line.
Sample Input 1
4
3 2 2 4
Sample Output 1
3
The length of a LIS of the given sequence is . For example, if you replace with , the length of a LIS of becomes , which is the maximum.
Sample Input 2
5
4 5 3 6 7
Sample Output 2
4