fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. int main(){
  6. int n,mx = 0,tmx = 0; cin >> n;
  7. vector<int> a(n);
  8. for(int i=0;i<n;i++) cin >> a[i];
  9. //vector<int> &a2 = a1;
  10. a.insert(a.end(),a.begin(),a.end());
  11.  
  12. for(int i=0;i<2*n;++i){
  13. if(a[i] == 1) ++tmx;
  14. else{
  15. mx = max(mx,tmx);
  16. tmx = 0;
  17. }
  18. }
  19. cout << mx;
  20. return 0;
  21. }
Success #stdin #stdout 0s 5280KB
stdin
5
1 0 1 1 0
stdout
2