Skip to content

Commit b57a31c

Browse files
committed
Create 1703F-YetAnotherProblemAboutPairsSatisfyingAnInequality.cpp
1 parent 6a5a6a4 commit b57a31c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <cstdio>
2+
#include <vector>
3+
typedef long long ll;
4+
5+
int main(){
6+
7+
ll t; scanf("%lld", &t);
8+
while(t--){
9+
ll n; scanf("%lld", &n);
10+
std::vector<ll> v(n + 1, 0);
11+
ll total(0);
12+
for(ll p = 1; p <= n; p++){
13+
ll x; scanf("%lld", &x);
14+
v[p] = v[p - 1];
15+
if(x < p){++v[p]; total += (x ? v[x - 1] : 0);}
16+
}
17+
18+
printf("%lld\n", total);
19+
}
20+
21+
}

0 commit comments

Comments
 (0)