/ OPS / 题库 /

Longest Inc Seq

Longest Inc Seq

#描述#
dd is playing a cut-sequence game. It gives a sequence of N numbers a[1], a[2], … a[N]. dd can remove at most two consecutive fragments. Then he computes the length of the longest consecutive increasing subsequence. What is the maximum possible length he can get?

#格式#
##输入格式##
The first line of the input is an integer T (T &lt= 100), which stands for the number of test cases you need to solve.

Each test case begins with an integer N (1 &lt= N &lt= 10^5) indicating the size of the sequence.

I ensure that 90% of the test data will satisfy N&lt=1000.

The next line contains N integers a[1], a[2], …, aN.

##输出格式##
For every test case, you should output "Case #k: " first, where k indicates the case number and starts at 1. Then output the maximum possible length of consecutive increasing subsequence after remove at most two consecutive fragments.

#样例1#
##样例输入1##

2
4
1 2 3 4
12
10 1 2 7 9 3 4 8 8 5 6 1

##样例输出1##

Case #1: 4
Case #2: 6

#限制#
1000ms
32768KB

#提示#
For the 2nd Case, we can remove 2 fragments 7 9 and 8 8, and get sequence 10 1 2 3 4 5 6 1. So the longest subsequence is 1 2 3 4 5 6.

#来源#

信息

ID
1845
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者