Cod sursa(job #1519864)
Utilizator | Data | 7 noiembrie 2015 22:26:45 | |
---|---|---|---|
Problema | Operatii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <bits/stdc++.h>
#define nmax 1000005
using namespace std;
ifstream fin("operatii.in");
ofstream fout("operatii.out");
int n;
int a[nmax];
int main()
{
long long sol;
int i;
fin >> n;
sol=0;
for(i = 1; i <= n; i++)
fin >> a[i];
for(i = 1; i <= n; i++)
if(a[i] > a[i - 1])
sol += a[i] - a[i - 1];
fout << sol;
return 0;
}