CF1703F.Yet Another Problem About Pairs Satisfying an Inequality
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…an . Count the number of pairs of indices 1≤i,j≤n such that ai<i<aj<j .
输入格式
The first line contains an integer t ( 1≤t≤1000 ) — the number of test cases.
The first line of each test case contains an integer n ( 2≤n≤2⋅105 ) — the length of the array.
The second line of each test case contains n integers a1,a2,…,an ( 0≤ai≤109 ) — the elements of the array.
It is guaranteed that the sum of n across all test cases does not exceed 2⋅105 .
输出格式
For each test case, output a single integer — the number of pairs of indices satisfying the condition in the statement.
Please note, that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
输入输出样例
输入#1
5 8 1 1 2 3 8 2 1 4 2 1 2 10 0 2 1 6 3 4 1 2 8 3 2 1 1000000000 3 0 1000000000 2
输出#1
3 0 10 0 1
说明/提示
For the first test cases the pairs are (i,j) = {(2,4),(2,8),(3,8)} .
- The pair (2,4) is true because a2=1 , a4=3 and 1<2<3<4 .
- The pair (2,8) is true because a2=1 , a8=4 and 1<2<4<8 .
- The pair (3,8) is true because a3=2 , a8=4 and 2<3<4<8 .