Cod sursa(job #3224433)

Utilizator Mihai_OctMihai Octavian Mihai_Oct Data 15 aprilie 2024 13:14:19
Problema Operatii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.36 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("operatii.in");
ofstream fout("operatii.out");
long long int r;
int n, i, x, u;

int main() {
    fin.tie(nullptr);
    fout.tie(nullptr);

    fin >> n;
    for(i = 1; i <= n; i++) {
        fin >> x;
        if(x > u) r += x - u;
        u = x;
    }
    fout << r;

    return 0;
}