Saleh127

cf 1406b

Sep 12th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. ll a[200000],c,d=0,e=0,f=0,i,j,k,l,m;
  14. cin>>c;
  15. for(i=1;i<=c;i++)
  16. {
  17. cin>>a[i];
  18. }
  19. sort(a+1,a+c+1);
  20. d=a[1]*a[2]*a[3]*a[4]*a[c];
  21. e=a[1]*a[2]*a[c-2]*a[c-1]*a[c];
  22. f=a[c-4]*a[c-3]*a[c-2]*a[c-1]*a[c];
  23. cout<<max(d,max(e,f))<<endl;
  24. }
  25. return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment