Cod sursa(job #303546)
Utilizator | Data | 9 aprilie 2009 23:06:37 | |
---|---|---|---|
Problema | Operatii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.29 kb |
#include <stdio.h>
int main()
{long int i,n,x,max=0,s=0;
freopen("operatii.in","r",stdin);
freopen("operatii.out","w",stdout);
scanf("%ld",&n);
for (i=1;i<=n;i++)
{ scanf("%ld",&x);
if (x==0) {s+=max;max=0;}
if (x>max) max=x;
}
s+=max;
printf("%ld\n",s);
return 0;}