-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path64475591.cpp
More file actions
40 lines (40 loc) · 725 Bytes
/
64475591.cpp
File metadata and controls
40 lines (40 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
queue<int> arr;
for(int i=0;i<n;i++)
{
int a;
scanf("%d",&a);
arr.push(a);
}
int flag=0;
while(arr.front()!=0 && flag<=n)
{
flag++;
arr.push(1);
arr.pop();
}
int maxi=0;
int counter=0;
for(int i=0;i<n;i++)
{
int k = arr.front();
arr.pop();
if(counter>0 && k==1)
counter++;
else if(k==1 && counter==0)
counter++;
else if(k==0)
{
maxi=max(maxi,counter);
counter=0;
}
}
maxi=max(maxi,counter);
cout<<maxi<<endl;
return 0;
}