CF446A.DZY Loves Sequences
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
DZY has a sequence a, consisting of n integers.
We'll call a sequence a__i, a__i + 1, ..., a__j (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing.
You only need to output the length of the subsegment you find.
DZY 有一个由 n 个整数组成的序列 a。
我们将序列 a 中形如 ai,ai+1,…,aj(其中 1≤i≤j≤n)的连续子序列称为一个子段(subsegment)。该子段的长度定义为 j−i+1。
你的任务是找出 a 的最长子段,使得至多修改该子段中的一个数(可将其改为任意整数),就能使该子段变为严格递增的。
你只需输出所找到的子段的长度。
输入格式
The first line contains integer n (1 ≤ n ≤ 105). The next line contains n integers _a_1, _a_2, ..., a__n (1 ≤ a__i ≤ 109).
第一行包含一个整数 n(1 ≤ n ≤ 105)。第二行包含 n 个整数 a1,a2,...,an(1 ≤ ai ≤ 109)。
输出格式
In a single line print the answer to the problem — the maximum length of the required subsegment.
在一行中输出问题的答案——所求子段的最大长度。
输入输出样例
输入#1
6 7 2 3 1 5 6
输出#1
5
说明/提示
You can choose subsegment _a_2, _a_3, _a_4, _a_5, _a_6 and change its 3rd element (that is _a_4) to 4.
你可以选择子段 a2, a3, a4, a5, a6,并将其第 3 个元素(即 a4)修改为 4。
输入解题思路,AI测评打分。不知道怎么写?