当前位置: 代码迷 >> 综合 >> UVA 11054 Wine trading in Gergovia .
  详细解决方案

UVA 11054 Wine trading in Gergovia .

热度:76   发布时间:2023-09-23 04:53:53.0

题目地址:http://vjudge.net/problem/UVA-11054

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b)  for(int i=a;i<=(int)(b);++i)
#define REPD(i,a,b) for(int i=a;i>=(int)(b);--i)
typedef long long LL;
int main(int argc, char const *argv[])
{LL n;while(scanf("%lld",&n)==1&&n){LL x,ans=0,now=0;REP(i,1,n){scanf("%lld",&x);ans+=abs(now);now+=x;}printf("%lld\n", ans);}return 0;
}