logo AlgoBeat OnlineJudge
登录 注册

#217807. [JAG 2026 Summer Camp #3] Self-Destruct Sequence

内存限制:2048 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are given a sequence of positive integers .

For each (), solve the following problem:

Let initially be the sequence . At any point during the process, let denote the current length of and let denote its -th element.

You may perform the following operation any number of times.

  • Choose an index () satisfying . Remove the elements from . The remaining elements, in their original order, form the new sequence .

Determine whether can be made empty. If so, find the minimum and maximum possible numbers of operations required.

输入格式

The input consists of a single test case of the following format.

N
A_1 A_2 ... A_N

The first line contains an integer (), representing the length of the sequence.

The second line contains integers ().

输出格式

Print lines.

For each (), the -th line should contain the answer for . If it is impossible to make empty, print -1. Otherwise, print two integers: the minimum and maximum possible numbers of operations required to make empty, respectively.

样例

样例输入 1

5
3 4 2 1 1

样例输出 1

-1
-1
1 1
2 2
2 3

样例输入 2

6
2 1 3 2 1 2

样例输出 2

-1
1 1
2 2
-1
2 3
3 4