solution-GERGOVIA - Wine trading in Gergovia
#include <stdio.h>
#include <math.h>
int main(void) {
while(1){
int n;
scanf("%d",&n);
if(n==0)
break;
int i,a[n],j,g;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
long long int s=0;
for(i=0;i<n;i++){
g=abs(a[i]);
s=s+g;
a[i+1]=a[i+1]+a[i];
}
printf("%lld\n",s);
}
return 0;
}
Comments
Post a Comment