We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6a5a6a4 commit b57a31cCopy full SHA for b57a31c
1703F-YetAnotherProblemAboutPairsSatisfyingAnInequality.cpp
@@ -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