ashu121

chefbest solution

Feb 6th, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int t,n;
  7. cin>>t;
  8. while(t--)
  9. {
  10. cin>>n;
  11. int s[n];
  12. int ans=0,change=0;
  13. for(int i=0;i<n;i++)
  14. cin>>s[i];
  15. for ( int i=0;i<n;i++)
  16. {
  17. if(s[i]==0)
  18. change++;
  19. else
  20. {
  21. if(change>0)
  22. ans=max(ans+1,change);
  23. }
  24. }
  25. cout<<ans<<endl;
  26. }
  27.  
  28. return 0;
  29. }
  30. //ashu326
Add Comment
Please, Sign In to add comment