Advertisement
a53

ProdMax1_SIMPLU

a53
Nov 8th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,x,Max1=-1000001,Max2=-1000001,Min1=1000001,Min2=1000001;
  7. cin>>n;
  8. for(int i=0;i<n;++i)
  9. {
  10. cin>>x;
  11. if(x>Max1)
  12. Max2=Max1,Max1=x;
  13. else
  14. if(x>Max2)
  15. Max2=x;
  16. if(x<Min1)
  17. Min2=Min1,Min1=x;
  18. else
  19. if(x<Min2)
  20. Min2=x;
  21. }
  22. if((long long)Min1*Min2>(long long)Max1*Max2)
  23. cout<<(long long)Min1*Min2;
  24. else
  25. cout<<(long long)Max1*Max2;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement