Result: Accepted
Time: 4ms
Memory: 1120kB
#include <stdio.h>
int main() {
int n,i,j,k;
float l,m,v;
while((scanf("%d",&n)) != EOF) {
int a[n];
for(i = 0;i < n;i++) {
scanf("%d",&a[i]);
}
if(a[0] < 0) {
k = 1;
l = a[0];
}else {
k = 0;
l = (double)a[0] / 2;
}
/*printf("%f ",l);*/
for(i = 1;i < n;i++) {
m = (double)a[i] / 2;
v = (double)a[i];
/*printf("%f %f ",m,v);*/
if(a[i] >= 0) {
if(l+m < 0) {
k++;
l += m;
}else {
l += m;
}
}else {
if(l + v >= 0) {
l += v ;
}else {
k++;
l += v;
}
}
}
printf("%d\n",k);
}
return 0;
}