Cod sursa(job #1594574)
Utilizator | Data | 9 februarie 2016 16:22:45 | |
---|---|---|---|
Problema | Operatii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.31 kb |
#include <fstream>
using namespace std;
ifstream fin("operatii.in");
ofstream fout("operatii.out");
int n,x,y;
long long s;
int main()
{
int i;
fin>>n>>x;
s = x;
for(i=2; i<=n; ++i)
{
fin>>y;
if(y > x)
s+=y-x;
x = y;
}
fout<<s;
}