#C7043. Strictly Increasing Subarrays Sum

    ID: 50871 Type: Default 1000ms 256MiB

Strictly Increasing Subarrays Sum

Strictly Increasing Subarrays Sum

You are given T test cases. In each test case, you are given an integer N and an array of N integers. Your task is to compute a value \(G\) for each test case, where \(G\) is defined as the total number of strictly increasing contiguous subarrays in the given array.

A strictly increasing subarray is a contiguous segment of the array in which every element is greater than the previous one. Formally, for an array \(a_1, a_2, \dots, a_N\), a subarray \(a_i, a_{i+1}, \dots, a_j\) (with \(1 \le i \le j \le N\)) is strictly increasing if \(a_k < a_{k+1}\) for every \(i \le k < j\). The value \(G\) is the sum of the counts of all such subarrays.

For example, consider the array [1, 2, 3, 4]. The strictly increasing subarrays are:

  • [1], [2], [3], [4] (each element by itself)
  • [1, 2], [2, 3], [3, 4]
  • [1, 2, 3], [2, 3, 4]
  • [1, 2, 3, 4]
Thus, \(G = 4 + 3 + 2 + 1 = 10\).

inputFormat

The input is given via standard input (stdin) and has the following format:

T
N
a1 a2 ... aN
N
a1 a2 ... aN
... (T test cases in total)

Where:

  • T is the number of test cases.
  • For each test case, the first line contains an integer N denoting the number of elements, followed by a line with N space-separated integers.

outputFormat

For each test case, output a single line containing the sum \(G\) — the total number of strictly increasing contiguous subarrays for that test case. The outputs should be printed to standard output (stdout).

## sample
4
4
1 2 3 4
5
5 4 2 1 3
4
4 3 2 1
4
1 1 1 1
10

6 4 4

</p>