1 solutions

  • 0
    @ 2026-11-14 11:36:56

    C++ :

    #include <bits/stdc++.h>
    using namespace std;
    
    
    int main(){
        int n,x,last = 0;
        long long ans = 0;
        cin >> n;
        
        for (int i = 1;i<=n;i++){
            cin >> x;   
            last = max(last+1,x);
            ans += last;
        }
        
        cout << ans;
        
        return 0;
    }
    
    • 1

    Information

    ID
    155
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    5
    Accepted
    4
    Uploaded By