Cod sursa(job #2712501)
Utilizator | Data | 25 februarie 2021 20:24:27 | |
---|---|---|---|
Problema | Operatii | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("operatii.in");
ofstream fout("operatii.out");
long long n,x;
long long sol;
int main()
{
long long i,cnt=0;
fin >> n;
for (i = 1; i <= n; i++)
{
fin >> x;
if (x == 0)
{
sol += cnt;
cnt = 0;
}
else cnt = max(cnt, x);
}
sol += cnt;
fout << sol;
return 0;
}