Pagini recente » Rating Victor Olaru (Ktekosi) | Cod sursa (job #1330014) | Cod sursa (job #880503) | Cod sursa (job #1396288) | Cod sursa (job #470176)
Cod sursa(job #470176)
#include<stdio.h>
#define ll long long
#define maxim(a,b) (a>b ? a : b)
int csec,n,v[1000006];
ll sol;
int main ()
{
int i;
freopen("operatii.in","r",stdin);
freopen("operatii.out","w",stdout);
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&v[i]);
for(i=1;i<=n+1;i++)
if(!v[i])
{
sol+=csec;
csec=0;
}
else
csec=maxim(csec,v[i]);
printf("%lld\n",sol);
return 0;
}