Cod sursa(job #1678154)

Utilizator StarGold2Emanuel Nrx StarGold2 Data 7 aprilie 2016 02:58:42
Problema Operatii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <bits/stdc++.h>

const int DIM = 1 << 20;
using namespace std;

int N, last, next; long long answer;

int main() {

    FILE *input_file  = fopen( "operatii.in" , "r" );
    FILE *output_file = fopen( "operatii.out", "w" );

    fscanf( input_file, "%d", &N );

    for( int i = 1; i <= N; i ++ ) {
        fscanf( input_file, "%d", &next );
        answer += max( next - last, 0 );
        last = next;
    }

    fprintf( output_file, "%lld\n", answer );

    return 0;
}