Cod sursa(job #1596176)
Utilizator | Data | 10 februarie 2016 20:41:36 | |
---|---|---|---|
Problema | Operatii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#include<fstream>
#include<algorithm>
#include<vector>
#include<stdlib.h>
using namespace std;
ifstream fin("operatii.in");
ofstream fout("operatii.out");
int main()
{
int n, i, s=0, maxx=0;
fin>>n;
int *v=(int*)malloc(n+1);
for(i=1; i<=n; i++){
fin>>v[i];
if(v[i]>maxx) s+=v[i]-maxx;
maxx=v[i]; }
fout<<s;
}