fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int t,a,count=0,temp=0;
  7. cin>>t;
  8. while(t--)
  9. {
  10. cin>>a;
  11. if(a)
  12. {
  13. temp++;
  14. }
  15. else
  16. {
  17. if(count<temp)
  18. {
  19. count=temp;
  20.  
  21. }
  22. temp=0;
  23. }
  24. }
  25. if(count<temp)
  26. count=temp;
  27. cout<<count;
  28. return 0;
  29. }
Time limit exceeded #stdin #stdout 15s 3296KB
stdin
Standard input is empty
stdout
Standard output is empty