Advertisement
zhukov000

Untitled

Mar 15th, 2020
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #define loop(i,from,to) for (int i = from; i < to; ++i)
  2. #define qAll(q) q.begin(), q.end()
  3. #define X first
  4. #define Y second
  5. #include <bits/stdc++.h>
  6.  
  7. using std::cin;
  8. using std::cout;
  9. using std::endl;
  10. using std::vector;
  11. using std::string;
  12. using std::pair;
  13. using std::set;
  14.  
  15. const int INF = 1e9+7;
  16. const double eps = 1e-6;
  17. template <typename T> void reverse(T &a) {
  18.   long long s = a.size();
  19.   for (long long i = 0; i < s / 2; ++i)
  20.     std::swap(a[i], a[s - i - 1]);
  21. }
  22.  
  23. long long S(int a, int b, int c) {
  24.   long long p = a + b + c;
  25.   return 1LL * p * (p - 2 * a) * (p - 2 * b) * (p - 2 * c);
  26. }
  27.  
  28. bool check(int a, int b, int c) {
  29.   return a + b > c && a + c > b && b + c > a;
  30. }
  31.  
  32. signed main() {
  33.   std::ios::sync_with_stdio(false);
  34.   cin.tie(0);
  35.   cout.tie();
  36.   int n, T; cin >> n;
  37.   vector<int> data;
  38.   loop(i, 0, n) {
  39.     cin >> T;
  40.     data.emplace_back(T);
  41.   }
  42.   if (n < 3) cout << -1;
  43.   else {
  44.     vector< pair<int, int> > sides;
  45.     loop(i, 0, n) sides.push_back({data[i], i + 1});
  46.     std::sort(sides.rbegin(), sides.rend());
  47.     bool f = false;
  48.     long long mx = -INF;
  49.     loop(i, 0, n - 2) {
  50.       int j = i + 1, k = i + 2;
  51.       if (check(sides[i].first, sides[j].first, sides[k].first)) {
  52.         assert(mx <= S(sides[i].first, sides[j].first, sides[k].first));
  53.         if (mx <= 0)
  54.         {
  55.           mx = S(sides[i].first, sides[j].first, sides[k].first);
  56.           cout << std::fixed << std::setprecision(6) <<
  57.             sqrt((long double) mx) / 4 << endl;
  58.           cout << sides[i].second << " " << sides[j].second << " " << sides[k].second;
  59.           f = true;
  60.         }
  61.       }
  62.     }
  63.     if (!f) cout << -1;
  64.   }
  65.   //std::cout << "Hello World!\n";
  66.   return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement