B - Maximal Continuous Rest
- #include<cstdio>
- #include<iostream>
- #include<algorithm>
- #include<string>
- #include<cstring>
- using namespace std;
- int n;
- int a[400005];
- int maxl=0;
- int main(){
- cin>>n;
- for(int i=1;i<=n;i++){
- cin>>a[i];a[i+n]=a[i];
- }
- int j;
- for(int i=1;i<=2*n;i++){
- if(a[i]==1){
- j=i;
- while(a[j+1]==1&&j<2*n)j++;
- maxl=max(maxl,j-i+1);
- i=j;
- }
- }
- cout<<maxl<<endl;
- }