Cod sursa(job #2606325)
Utilizator | Data | 27 aprilie 2020 15:41:52 | |
---|---|---|---|
Problema | Operatii | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("operatii.in");
ofstream g("operatii.out");
int main()
{
long long n, nr = 0, last = 0, x;
f >> n;
for(int i = 1; i <= n; i++)
{
f >> x;
if(x == 0)
{
nr += last;
last = 0;
}
last = max(last, x);
}
if(last != 0)
nr += last;
g << nr;
return 0;
}