- BC20260025's blog
NOIP练习
- 2024-11-20 10:13:28 @
A
# include<iostream>
using namespace std;
# define ll long long
const int N=52;
int t,n;
ll a[N],ans;
void solve(){
cin>>n;
ans=0;a[n]=-1;
for(int i=0;i<n;++i) cin>>a[i];
for(int i=n;i>=0;--i)
if(a[i]<0){
ans-=a[i];
for(int j=0;j<i;++j) a[j]+=a[i];
a[i]=0;
}
cout<<ans<<endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>t;
while(t--) solve();
return 0;
}