Advertisement
Guest User

Untitled

a guest
Mar 17th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n,a[1000000],p[1000000],kon1=0,kon2=0,kon3=0,kon4=0;
  4.  
  5. int main()
  6. {
  7. cin>>n;
  8. for (int i=0; i<n; i++)
  9. {
  10. cin>>a[i];
  11. }
  12. if (a[0]==0)
  13. {
  14. for (int i=n; i>=0; i--)
  15. {
  16. if (a[i]==1) {kon1=i; break;}
  17. }
  18. }
  19. if (a[0]==1)
  20. {
  21. for (int i=n; i>=0; i--)
  22. {
  23. if (a[i]==0) {kon2=i-1; break;}
  24. }
  25. }
  26. if (a[n-1]==0)
  27. {
  28. for (int i=0; i<n; i++)
  29. {
  30. if (a[i]==1) {kon3=(n-1)-1; break;}
  31. }
  32. }
  33. if (a[n-1]==1)
  34. {
  35. for (int i=0; i<n; i++)
  36. {
  37. if (a[i]==0) {kon4=(n-1); break;}
  38. }
  39. }
  40. if (kon1>kon2 && kon1>kon3 && kon1>kon4) cout<<kon1;
  41. else if (kon2>kon1 && kon2>kon3 && kon2>kon4) cout<<kon2;
  42. else if (kon3>kon1 && kon3>kon2 && kon3>kon4) cout<<kon3;
  43. else cout<<kon4;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement