Cod sursa(job #2712506)

Utilizator tomaionutIDorando tomaionut Data 25 februarie 2021 20:30:27
Problema Operatii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.33 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("operatii.in");
ofstream fout("operatii.out");
long long n,x,y;
long long sol;
int main()
{	
	long long i,cnt=0;
	fin >> n;
	fin >> x;
	sol = x;
	for (i = 2; i <= n; i++)
	{
		fin >> y;
		if (y > x)
			sol += y - x;
		x = y;
	}
	fout << sol;


	return 0;
}