题解
太巧妙了!!
层加式?
code
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[100005]={0};
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
ll suf=a[n],ans=a[n];
for(int i=n-1;i>=1;i--)
{
ans+=max(a[i],a[i]+suf);
suf+=a[i];
}
cout<<ans<<endl;
}
return 0;
}
标签:suf,int,Theofanis,long,Nightmare,ans,ll
From: https://www.cnblogs.com/pure4knowledge/p/18099836