Cod sursa(job #2269766)
| Utilizator | Data | 26 octombrie 2018 16:18:16 | |
|---|---|---|---|
| Problema | Cautare binara | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream ("maxsecv.in");
ofstream ("maxsecv.out");
int n,v[1000005];
void read()
{
fin>>n;
for(i=1;i<=n;i++)
fin>>v[i];
}
void solve()
{
int i,ct=0,lgmax1=0,lgmax2=0;
for(i=1;i<=n;i++)
{
if(v[i]==1)
ct++;
else ct=0;
if(ct>lgmax1) lgmax1=ct;
else if(ct>lgmax2) lgmax2=ct;
}
fout<<lgmax1+lgmax2;
}
int main()
{
read();
solve();
}
