Cod sursa(job #129484)
Utilizator | Data | 29 ianuarie 2008 16:21:28 | |
---|---|---|---|
Problema | Operatii | Scor | 100 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<stdio.h>
int main()
{
FILE *f=fopen("operatii.in","r");
int i,n,v[1000000];
long long nr;
fscanf(f,"%i",&n);
for(i=0;i<n;i++)
fscanf(f,"%i",&v[i]);
nr=v[0];
for(i=0;i<n-1;i++)
{
if(v[i+1]>v[i])
nr+=v[i+1]-v[i];
}
fclose(f);
f=fopen("operatii.out","w");
fprintf(f,"%lli",nr);
fclose(f);
return 0;
}