Cod sursa(job #181026)

Utilizator stef2nStefan Istrate stef2n Data 17 aprilie 2008 19:59:08
Problema Operatii Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.32 kb
#include <fstream>
using namespace std;

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

int main() {
    int N, last = 0, now, cnt = 0;
    in >> N;
    for(int i = 0; i < N; ++i) {
        in >> now;
        cnt += (last < now ? now - last : 0);
        last = now;
    }
    out << cnt << "\n";
    return 0;
}