Cod sursa(job #1758641)
Utilizator | Data | 17 septembrie 2016 16:22:23 | |
---|---|---|---|
Problema | Multiplu | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <cstdio>
using namespace std;
int main(){
FILE *in = fopen("operatii.in", "r");
int n, i, l = 0, x;
long long rez = 0;
fscanf(in, "%d", &n);2
for(i = 0; i < n; i++){
fscanf(in, "%d", &x);
if(x > l)
rez += x - l;
l = x;
}
fclose(in);
FILE *out = fopen("operatii.out", "w");
fprintf(out, "%lld", rez);
fclose(out);
return 0;
}