Cod sursa(job #966336)
Utilizator | Data | 25 iunie 2013 18:56:35 | |
---|---|---|---|
Problema | Operatii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include <cstdio>
#include <algorithm>
using namespace std;
#define LL long long
int i, N;
int x, Vm;
LL ANS;
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 > Vm)
ANS += x - Vm;
Vm = x;
}
printf("%lld\n", ANS);
return 0;
}