Cod sursa(job #2218376)

Utilizator stelian2000Stelian Chichirim stelian2000 Data 4 iulie 2018 12:57:11
Problema Operatii Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.36 kb
#include <bits/stdc++.h>

using namespace std;

int main()
{
    freopen("operatii.in","r",stdin);
    freopen("operatii.out","w",stdout);
    int n,x,prev=0;
    long long ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(x>prev) ans+=x-prev;
        prev=x;
    }
    printf("%lld",ans);
    return 0;
}