挺简单的小模拟。
还是要注意思维的方向,要有切入点,不能像无头苍蝇一样东想一下西想一下,而应该分析问题的性质,然后尝试思维的方向,从不同的方向思考(顺序,逆序,排序后,建图,贪心,dp,搜索等等)
时刻注意数据的范围,时刻提防爆long long ,不注意往往死的莫名其妙的
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<climits>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int n;
ll tmp,cur,ans;int main()
{while(~scanf("%d",&n) && n){cur=0;ans=0;for(int i=0;i<n;i++){scanf("%lld",&tmp);cur+=tmp;ans+=abs(cur);}printf("%lld\n",ans);}return 0;
}