Cod sursa(job #3367351)

Utilizator _someone_Lupulescu Vlad _someone_ Data 7 octombrie 2026 10:27:04
Problema Operatii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.33 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream fin("operatii.in");
ofstream fout("operatii.out");
int main()
{
long long n;
fin>>n;
long long op=0;
long long x1,x2;
fin>>x1;
op=x1;
for(int i=1;i<n;i++)
{
    x2=x1;
    fin>>x1;

    if(x1>x2)
    op=op+x1-x2;
}
cout<<op;
fout<<op;
return 0;
}