Dang_Quan_10_Tin

TICHMAX TS10 PTNK 2007-2008

Jan 15th, 2022
756
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define task "TICHMAX"
  2.  
  3. #include <iostream>
  4. #include <cstdio>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. using ll = long long;
  10. using ld = long double;
  11.  
  12. constexpr int N = 1e4 + 5;
  13. int n, a[N];
  14.  
  15. void Read()
  16. {
  17.     cin >> n;
  18.  
  19.     for (int i = 1; i <= n; ++i)
  20.         cin >> a[i];
  21. }
  22.  
  23. void Solve()
  24. {
  25.     sort(a + 1, a + n + 1);
  26.  
  27.     cout << max(1ll * a[n] * a[n - 1] * a[n - 2], 1ll * a[1] * a[2] * a[n]);
  28. }
  29.  
  30. int32_t main()
  31. {
  32.     ios::sync_with_stdio(0);
  33.     cin.tie(0);
  34.     cout.tie(0);
  35.     if (fopen(task ".INP", "r"))
  36.     {
  37.         freopen(task ".INP", "r", stdin);
  38.         freopen(task ".OUT", "w", stdout);
  39.     }
  40.  
  41.     Read();
  42.     Solve();
  43. }
  44.  
RAW Paste Data