General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
164005949 Practice:
AVdovin
1703F - 23 C++20 (GCC 11-64) Accepted 46 ms 1616 KB 2022-07-13 11:27:51 2022-07-13 11:27:54
→ Source
#include <bits/stdc++.h>

using namespace std;

#define sri(a) sort(a.begin(), a.end())
#define ll long long
#define pb push_back
#define vc vector
#define F first
#define S second
#define sz(a) (int)a.size()

/*
1. a
2. b
3. c
4. d
5. e
6. f
7. g
8. h
9. i
10. j
11. k
12. l
13. m
14. n
15. o
16. p
17. q
18. r
19. s
20. t
21. u
22. v
23. w
24. x
25. y
26. z
*/

const int INF = 1e9 + 1416, MOD = 1e9 + 7;
const double pi = 3.1415926535;

void solve(int test) {
    int n; cin >> n;
    vc<int> a(n);
    vc<bool> p(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        p[i] = (a[i] < i + 1);

    }
    vc<int> pref(n);
    pref[0] = p[0];
    for (int i = 1; i < n; i++) pref[i] = pref[i - 1] + p[i];
    //for (int i = 0; i < n; i++) cout << pref[i] << ' ';
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        if (p[i] == true && a[i] >= 2) {
            ans += pref[a[i] - 2];
        }
    }
    cout << ans;
    return;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    srand(time(0));
    int t = 1; cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
        cout << endl;
    }
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details