CF1736C1.Good Subarrays (Easy Version)

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

This is the easy version of this problem. In this version, we do not have queries. Note that we have multiple test cases in this version. You can make hacks only if both versions of the problem are solved.

An array bb of length mm is good if for all ii the ii -th element is greater than or equal to ii . In other words, bb is good if and only if biib_i \geq i for all ii ( 1im1 \leq i \leq m ).

You are given an array aa consisting of nn positive integers. Find the number of pairs of indices (l,r)(l, r) , where 1lrn1 \le l \le r \le n , such that the array [al,al+1,,ar][a_l, a_{l+1}, \ldots, a_r] is good.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t21051 \leq t \leq 2 \cdot 10^5 ). Description of the test cases follows.

The first line of each test case contains an integer nn ( 1n21051 \leq n \leq 2 \cdot 10^5 ), the length of the array aa .

The second line of each test case contains nn space-separated integers a1,a2,,ana_1,a_2,\ldots,a_n ( 1ain1 \leq a_i \leq n ), representing the array aa .

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, print the number of suitable pairs of indices.

输入输出样例

  • 输入#1

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

    输出#1

    6
    3
    7

说明/提示

In the first test case, all subarrays of aa are good, so all pairs are suitable.

In the second test case, the pairs (1,1)(1, 1) , (2,2)(2, 2) , and (3,3)(3, 3) are suitable. For example, when (l,r)=(1,2)(l, r) = (1, 2) , the array b=[1,1]b=[1,1] is not good because b2<2b_2 < 2 .

首页