Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int n,i,j,k,x,y=0;
- int a[100];
- int b[100];
- int main()
- {
- cin>>n;
- for(x=1;x<=n;x++)
- cin>>a[x];
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- {
- if(i<=j)
- {
- k=0;
- for(x=1;x<=n;x++)
- b[x]=a[x];
- for(x=i;x<=j;x++)
- {
- b[x]=1-b[x];
- }
- for(x=1;x<=n;x++)
- if(b[x]==1)
- k++;
- if(y<=k)
- y=k;
- }}
- cout<<y<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement