Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. //ifstream f("saci.in");
  7. //ofstream g("saci.out");
  8.  
  9. int main()
  10. {
  11. int n,i,j=0,maxim=0,nr=0,x;
  12. cin>>n;
  13. for(i=1;i<=n;i++)
  14. {
  15. cin>>x;
  16. if(x==0)
  17. nr++;
  18. else
  19. {
  20. if(nr>maxim)
  21. {
  22. maxim=nr;
  23. j=i-1;
  24. }
  25. nr=0;
  26. }
  27. }
  28. if(x==0)
  29. {
  30. if(nr>maxim)
  31. {
  32. maxim=nr;
  33. j=i-1;
  34. }
  35. nr=0;
  36. }
  37. x=j-maxim+1;
  38. cout<<x<<" "<<j;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement