Pagini recente » Cod sursa (job #938414) | Cod sursa (job #2108249) | Cod sursa (job #1946676) | Cod sursa (job #1035675) | Cod sursa (job #1726649)
#include <fstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <math.h>
using namespace std;
#define ll long long
#define llu long long unsigned
#define pb push_back
#define mp make_pair
string problemName = "operatii";
string inFile = problemName+".in";
string outFile = problemName+".out";
ifstream fin(inFile.c_str());
ofstream fout(outFile.c_str());
int main(){
int n,i,x,y;
y = 0;
llu sol = 0;
fin>>n;
for(i = 1;i <= n;i++){
fin>>x;
if(x > y){
sol += x-y;
}
y = x;
}
fout<<sol;
return 0;
}