Cod sursa(job #1167382)
Utilizator | Data | 4 aprilie 2014 21:28:12 | |
---|---|---|---|
Problema | Operatii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
using namespace std ;
const int NMAX = 1000005 ;
ifstream cin("operatii.in") ;
ofstream cout("operatii.out") ;
long long N, X, P, R ;
long long V[NMAX] ;
int main()
{
cin >> P ;
for(int i = 1 ;i <= P ; ++ i)
{
cin >> N ;
X < N ? R = R + N - X : R ;
X = N;
}
cout << R << '\n' ;
cin.close() ;
cout.close() ;
return 0 ;
}