Cod sursa(job #2174461)

Utilizator BogdanFaciuIntaiulMare Lake BogdanFaciuIntaiul Data 16 martie 2018 12:10:04
Problema Operatii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.51 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("operatii.in");
ofstream g("operatii.out");

long long n, i, s, x, last ;


int main()
{
    f>>n;
    for(i=1;i<=n;i++)
            {
                f>>x;
                if(x==0)
                {
                    s=s+last;
                    last=1LL*x;

                }
                else if(last<x)
                    {
                        last=1LL*x;
                    }

            }
    g<<s+last;

    return 0;
}