Cod sursa(job #1516829)
Utilizator | Data | 3 noiembrie 2015 17:13:22 | |
---|---|---|---|
Problema | Operatii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("operatii.in");
ofstream fout("operatii.out");
int n,x,mx;
long long cnt;
int main()
{
int i,x,last;
fin>>n>>last;
cnt = last;
for(i=2;i<=n;i++)
{
fin>>x;
if(x>last)
cnt+=x-last;
last = x;
}
fout<<cnt<<"\n";
fout.close();
return 0;
}