CF1882A.Increasing Sequence

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a sequence a1,a2,,ana_{1}, a_{2}, \ldots, a_{n} . A sequence b1,b2,,bnb_{1}, b_{2}, \ldots, b_{n} is called good, if it satisfies all of the following conditions:

  • bib_{i} is a positive integer for i=1,2,,ni = 1, 2, \ldots, n ;
  • biaib_{i} \neq a_{i} for i=1,2,,ni = 1, 2, \ldots, n ;
  • b1<b2<<bnb_{1} < b_{2} < \ldots < b_{n} .

Find the minimum value of bnb_{n} among all good sequences b1,b2,,bnb_{1}, b_{2}, \ldots, b_{n} .

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t1001 \le t \le 100 ). The description of the test cases follows.

The first line of each test case contains a single integer nn ( 1n1001 \le n \le 100 ).

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai1091 \le a_i \le 10^{9} ).

输出格式

For each test case, print a single integer — the minimum value of bnb_{n} among all good sequences bb .

输入输出样例

  • 输入#1

    3
    5
    1 3 2 6 7
    4
    2 3 4 5
    1
    1

    输出#1

    8
    4
    2

说明/提示

In the first test case, b=[2,4,5,7,8]b = [2, 4, 5, 7, 8] is a good sequence. It can be proved that there is no good bb with b5<8b_{5} < 8 .

In the second test case, b=[1,2,3,4]b = [1, 2, 3, 4] is an optimal good sequence.

In the third test case, b=[2]b = [2] is an optimal good sequence.

首页