[Solution] Good Subarrays (Easy Version) Codeforces Solution
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 of length is good if for all the -th element is greater than or equal to . In other words, is good if and only if for all ().
You are given an array consisting of positive integers. Find the number of pairs of indices , where , such that the array is good.
Each test contains multiple test cases. The first line contains the number of test cases (). Description of the test cases follows.
The first line of each test case contains an integer (), the length of the array .
The second line of each test case contains space-separated integers (), representing the array .
It is guaranteed that the sum of over all test cases does not exceed .
For each test case, print the number of suitable pairs of indices.
In the first test case, all subarrays of are good, so all pairs are suitable.
In the second test case, the pairs , , and are suitable. For example, when , the array is not good because .
No comments:
Post a Comment