Cod sursa(job #966328)
Utilizator | Data | 25 iunie 2013 18:44:29 | |
---|---|---|---|
Problema | Operatii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <cstdio>
#include <algorithm>
using namespace std;
int i, N, ANS;
int x, y, Vm;
int main() {
freopen("operatii.in","r",stdin);
freopen("operatii.out","w",stdout);
scanf("%i", &N);
for (i = 1; i <= N; ++i) {
scanf("%i", &x);
if (x == 0) {
ANS += Vm;
Vm = 0;
}
else
Vm = max(Vm, x);
}
if (x != 0) ANS += Vm;
printf("%i\n", ANS);
return 0;
}