Cod sursa(job #1290204)

Utilizator eu3neuomManghiuc Teodor-Florin eu3neuom Data 10 decembrie 2014 22:17:12
Problema Operatii Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 kb
#include <iostream>
#include <fstream>

using namespace std;

ifstream f("operatii.in");
ofstream g("operatii.out");

int main()
{
    int n,last,sol = 0,x;
    f >> n;
    f >> last;
    if(last != 0)
        sol += last;
    for(int i = 2; i <= n; i++){
        f >> x;
        if(x > last)
            sol = sol + x - last;
        last = x;
    }
    g << sol;
    return 0;
}