关于我写签到题忘开LONGLONG

· · 闲话

https://vjudge.net/problem/Gym-106589K

就这题,不开LONGLONG见祖宗

#include<bits/stdc++.h>
using namespace std;
namespace alldef{
    #define int long long//已逝
    #define N 200005
}
using namespace alldef;
namespace strc{
    struct NODE{
        int x,id;
    };
}
using namespace strc;
namespace init{
    int n;
    int d[N],ans[N];
    stack<NODE> st;
}
using namespace init;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>d[i];
    for(int i=n;i>=1;i--){
        while(!st.empty() and d[i]+i>=st.top().x) st.pop();
        if(st.empty()) ans[i]=d[i]*d[i];
        else{
            int tmp=st.top().id;
            ans[i]=ans[tmp]+(2*d[i]-tmp+i)*(tmp-i);
        }
        st.push({d[i]+i,i});
    }
    for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';
    return 0;
}