CF1882A.Increasing Sequence

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

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;
  • bi≠aib_{i} \neq a_{i} for i=1,2,…,ni = 1, 2, \ldots, n;
  • b1<b2<…<bnb_{1} \lt b_{2} \lt \ldots \lt b_{n}.

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

给定一个序列 a1,a2,…,ana_{1}, a_{2}, \ldots, a_{n}。若序列 b1,b2,…,bnb_{1}, b_{2}, \ldots, b_{n} 满足以下所有条件,则称其为好序列:

  • 对于 i=1,2,…,ni = 1, 2, \ldots, n,bib_{i} 是正整数;
  • 对于 i=1,2,…,ni = 1, 2, \ldots, n,bi≠aib_{i} \neq a_{i};
  • b1<b2<…<bnb_{1} \lt b_{2} \lt \ldots \lt b_{n}。

求所有好序列 b1,b2,…,bnb_{1}, b_{2}, \ldots, b_{n} 中 bnb_{n} 的最小可能值。

输入格式

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

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

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

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1001 \le t \le 100)。随后是测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \le n \le 100)。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1091 \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.

对于每个测试用例,输出一个整数——所有好序列 bb 中 bnb_{n} 的最小值。

输入输出样例

  • 输入#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} \lt 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.

在第一个测试用例中,b=[2,4,5,7,8]b = [2, 4, 5, 7, 8] 是一个好序列。可以证明:不存在满足 b5<8b_{5} \lt 8 的好序列 bb。

在第二个测试用例中,b=[1,2,3,4]b = [1, 2, 3, 4] 是一个最优的好序列。

在第三个测试用例中,b=[2]b = [2] 是一个最优的好序列。

输入解题思路,AI测评打分。不知道怎么写?

首页