Cod sursa(job #2229843)

Utilizator Moise_AndreiMoise Andrei Moise_Andrei Data 8 august 2018 11:30:22
Problema Operatii Scor 80
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.33 kb
#include <bits/stdc++.h>
using namespace std;
ifstream in("operatii.in");
ofstream out("operatii.out");
int v[1000005];
int main()
{
    int n, s = 0;
    in >> n;
    for(int i = 1; i <= n; i ++)
    {
        in >> v[i];
        if(v[i - 1] <= v[i])
            s += (v[i] - v[i - 1]);
    }
    out << s;
    return 0;
}