Cod sursa(job #2174399)

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

long long n, i, j, s, x, last ;
bool complet;

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

                }
                else if(last<x)
                    {
                        last=x;
                    }

            }
    g<<s+last;

    return 0;
}