- 取石子
tung tung tung sahur
- 2025-8-8 18:17:02 @
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[1000010];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,wz=0,cnt=0;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int i=1;i<=n;i++){
wz+=a[i];
if(wz<0){
cnt+=abs(wz);
wz=0;
}
}
cout<<cnt;
return 0;
}
1 条评论
-
盖明喆 @ 2025-8-9 15:43:58
又是水题题解
- 1
信息
- ID
- 116
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 56
- 已通过
- 9
- 上传者