Cod sursa(job #3146536)

Utilizator rares89_Dumitriu Rares rares89_ Data 21 august 2023 15:14:29
Problema Operatii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.34 kb
#include <fstream>

using namespace std;

ifstream fin("operatii.in");
ofstream fout("operatii.out");

int main() {
    int n, x, ant = 0;
    long long int ans = 0;
    fin >> n;
    for(int i = 1; i <= n; i++) {
        fin >> x;
        if(x > ant) {
            ans += (x - ant);
        }
        ant = x;
    }
    fout << ans;
    return 0;
}