Cod sursa(job #1515717)

Utilizator dnprxDan Pracsiu dnprx Data 2 noiembrie 2015 08:51:58
Problema Operatii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int i, n, x, y;
    long long cnt = 0;
    ifstream fin("operatii.in");
    ofstream fout("operatii.out");
    fin >> n;
    x = 0;
    for (i = 1; i <= n; ++i)
    {
        fin >> y;
        if (y > x) cnt += (y - x);
        x = y;
    }
    fout << cnt << "\n";
    fin.close();
    fout.close();
    return 0;
}