Problem:
Problem E:
HullMarathon
うさぎはフルマラソンという競技が好きである. この競技はチームで行う. チームメンバーは競技開始前に原点に集まる. 競技開始と同時に走り出し, 1 分後に立ち止まる．このとき，チームメンバーの位置の凸包の面積が最も大きなチームが勝ちとなる.
あなたは $N$ 匹のうさぎからなるチームの監督である. $i$ 匹目のうさぎは 1 分で $r_i$ 移動することができる. このチームが最適な戦略をとった場合の, 1 分後の凸包の面積の最大値を求めよ.
Constraints
$N$ will be between 3 and 8, inclusive.
$r_i$ will be an integer between 1 and 1,000, inclusive.
Input
入力は以下の形式で与えられる:
$N$
$r_1$
...
$r_N$
Output
凸包の面積の最大値を表す実数を 1 行に出力せよ. 小数点以下何桁出力してもよいが, 絶対誤差または相対誤差が $10^{-6}$ 以下のとき Accepted になる.
Sample Input 1
4
5
8
58
85
Sample Output 1
2970.000000000
Sample Input 2
6
1
1
1
1
1
1
Sample Output 2
2.598076211

Submitted solutions:

code_snippet: #include<bits/stdc++.h>

using namespace std;
#define rep2(i, j, k) for(ll i=ll(j);i<ll(k);i++)
#define rep(i, j) rep2(i,0,j)
#define rrep2(i, j, k) for(ll i=ll(j)-1;i>=ll(k);i--)
#define rrep(i, j) rrep2(i,j,0)
#define SZ(a) ll(a.size())
#define eb emplace_back
#define all(a) a.begin(),a.end()
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vvp = vector<vp>;
const ll inf = LLONG_MAX / 4;

template<class T>
bool chmin(T &a, T b) { return a > b ? a = b, 1 : 0; }

template<class T>
bool chmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

const double PI = acos(-1);

double f(const vl &r) {
    int n = SZ(r);
    vector<double> v(n);
    rep(i, n) v[i] = r[i] * r[(i + 1) % n] * 0.5;
    auto check = [&](double x) -> bool {
        double s = 0;
        rep(i, n) {
            if (x <= -v[i]) {
                s += PI;
            } else if (x < v[i]) {
                s += acos(x / v[i]);
            }
        }
        return s >= PI * 2;
    };
    double ok = -1e6, ng = 1e6;
    rep(_, 100) {
        double mid = (ok + ng) / 2;
        if (check(mid)) ok = mid;
        else ng = mid;
    }
    double res = 0;
    rep(i, n) {
        double th;
        if (ok <= -v[i]) {
            th = PI;
        } else if (ok < v[i]) {
            th = acos(ok / v[i]);
        } else {
            th = 0;
        }
        res += v[i] * sin(th);
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    vl r(n);
    rep(i, n) cin >> r[i];
    vl nr;
    vector<bool> used(n);
    double ans = 0;
    auto dfs = [&](auto &dfs) -> void {
        if (SZ(nr) >= 3) chmax(ans, f(nr));
        rep(i, n) {
            if (used[i]) continue;
            nr.eb(r[i]);
            used[i] = true;
            dfs(dfs);
            used[i] = false;
            nr.pop_back();
        }
    };
    dfs(dfs);
    cout << fixed << setprecision(15) << ans << endl;
}
accuracy: 1
time_ms: 5620
memory_kb: 4172
final_rank: 13

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

long double PI = 3.14159265358979323846264;
long double eps = 1e-8;

long double Solve(vector<long double> R) {
    int N = R.size();
    long double Le = -inf, Ri = inf;
    rep(_,0,100) {
        long double MID = (Le+Ri) * 0.5L;
        long double SUM = 0.0;
        rep(i,0,N) {
            long double X = MID / (R[i]*R[(i+1)%N]);
            chmax(X, -1.0+eps);
            chmin(X, 1.0-eps);
            long double Theta = acos(X);
            SUM += Theta;
        }
        if (SUM >= PI * 2.0L) Le = MID;
        else Ri = MID;
    }
    long double Ret = 0;
    rep(i,0,N) {
        long double Theta = acos(Le / (R[i]*R[(i+1)%N]));
        Ret += R[i]*R[(i+1)%N] * sin(Theta) * 0.5L;
    }
    return Ret;
}

int main() {
    int N;
    cin >> N;
    vector<long double> R(N);
    rep(i,0,N) cin >> R[i];
    long double ANS = 0.0;
    rep(i,0,1<<N) {
        vector<long double> S;
        rep(j,0,N) {
            if (i & (1<<j)) S.push_back(R[j]);
        }
        if ((int)S.size() < 3) continue;
        int M = S.size();
        vector<int> ord(M);
        iota(ALL(ord),0);
        do {
            vector<long double> T(M);
            rep(j,0,M) {
                T[j] = S[ord[j]];
            }
            chmax(ANS, Solve(T));
        } while(next_permutation(ALL(ord)));
    }
    printf("%.12Lf\n", ANS);
}
accuracy: 1
time_ms: 4830
memory_kb: 3956
final_rank: 11

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

/**
 * @brief template
 */

long double PI = 3.14159265358979323846264;

long double Solve(vector<long double> R) {
    int N = R.size();
    long double MIN = inf;
    rep(i,0,N) {
        chmin(MIN, R[i] * R[(i+1)%N]);
    }
    long double Le = -MIN, Ri = MIN;
    rep(_,0,100) {
        long double MID = (Le+Ri) * 0.5L;
        long double SUM = 0.0;
        rep(i,0,N) {
            long double Theta = acos(MID / (R[i]*R[(i+1)%N]));
            SUM += Theta;
        }
        if (SUM >= PI * 2.0L) Le = MID;
        else Ri = MID;
    }
    long double Ret = 0;
    rep(i,0,N) {
        long double Theta = acos(Le / (R[i]*R[(i+1)%N]));
        Ret += R[i]*R[(i+1)%N] * sin(Theta) * 0.5L;
    }
    return Ret;
}

int main() {
    int N;
    cin >> N;
    vector<long double> R(N);
    rep(i,0,N) cin >> R[i];
    long double ANS = 0.0;
    rep(i,0,1<<N) {
        vector<long double> S;
        rep(j,0,N) {
            if (i & (1<<j)) S.push_back(R[j]);
        }
        if ((int)S.size() < 3) continue;
        int M = S.size();
        vector<int> ord(M);
        iota(ALL(ord),0);
        do {
            vector<long double> T(M);
            rep(j,0,M) {
                T[j] = S[ord[j]];
            }
            chmax(ANS, Solve(T));
        } while(next_permutation(ALL(ord)));
    }
    printf("%.12Lf\n", ANS);
}

/*
x_i x_(i+1) sin theta_i
*/
accuracy: 0.6060606060606061
time_ms: 470
memory_kb: 3904
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define revrep(i, t, s) for (int i = (int)(t) - 1; i >= (int)(s); --i)
#define all(x) begin(x), end(x)
template <typename T>
bool chmax(T& a, const T& b) {
    return a < b ? (a = b, 1) : 0;
}
template <typename T>
bool chmin(T& a, const T& b) {
    return a > b ? (a = b, 1) : 0;
}

template <typename F>
double golden_section_search(F f, double lb, double ub, int iter = 100) {
    // constexpr auto phi = std::numbers::phi;
    constexpr auto phi = (1. + sqrt(5.)) / 2.;
    double m1 = ub - (ub - lb) / phi;
    double m2 = lb + (ub - lb) / phi;
    auto v1 = f(m1), v2 = f(m2);
    for (int i = 0; i < iter; ++i) {
        if (v1 < v2) {
            ub = m2;
            m2 = m1;
            v2 = v1;
            m1 = ub - (ub - lb) / phi;
            v1 = f(m1);
        } else {
            lb = m1;
            m1 = m2;
            v1 = v2;
            m2 = lb + (ub - lb) / phi;
            v2 = f(m2);
        }
    }
    return lb;
}

const double PI = acos(-1);

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (int i = 0; i < (int)v.size(); ++i) {
        os << v[i];
        if (i < (int)v.size() - 1) os << " ";
    }
    return os;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;
    vector<double> r(N);
    for (auto& x : r) cin >> x;

    double ans = 0;
    rep(S, 1, 1 << N) {
        vector<int> idx;
        rep(i, 0, N) if (S >> i & 1) idx.push_back(i);
        if (idx.size() <= 2) continue;

        auto f = [&](double lam, bool check = false) {
            double sumarea = 0;
            double sumtheta = 0;
            rep(i, 0, idx.size()) {
                double theta =
                    acos(2. * lam / (r[idx[i]] * r[idx[(i + 1) % idx.size()]]));
                sumarea +=
                    0.5 * r[idx[i]] * r[idx[(i + 1) % idx.size()]] * sin(theta);
                sumtheta += theta;
            }
            return sumarea - lam * (sumtheta - 2 * PI);
        };

        do {
            double x = 1e7;
            rep(i, 0, idx.size())
                chmin(x, 0.5 * r[idx[i]] * r[idx[(i + 1) % idx.size()]]);
            double lam = golden_section_search(f, -x, x, 100);

            double sumtheta = 0;
            rep(i, 0, idx.size()) {
                double theta =
                    acos(2. * x / (r[idx[i]] * r[idx[(i + 1) % idx.size()]]));
                sumtheta += theta;
            }
            if (sumtheta > 2 * PI) continue;

            chmax(ans, f(lam));
        } while (next_permutation(all(idx)));
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 2580
memory_kb: 4196
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (int i = (int)(s); i < (int)(t); ++i)
#define revrep(i, t, s) for (int i = (int)(t) - 1; i >= (int)(s); --i)
#define all(x) begin(x), end(x)
template <typename T>
bool chmax(T& a, const T& b) {
    return a < b ? (a = b, 1) : 0;
}
template <typename T>
bool chmin(T& a, const T& b) {
    return a > b ? (a = b, 1) : 0;
}

template <typename F>
double golden_section_search(F f, double lb, double ub, int iter = 100) {
    // constexpr auto phi = std::numbers::phi;
    constexpr auto phi = (1. + sqrt(5.)) / 2.;
    double m1 = ub - (ub - lb) / phi;
    double m2 = lb + (ub - lb) / phi;
    auto v1 = f(m1), v2 = f(m2);
    for (int i = 0; i < iter; ++i) {
        if (v1 < v2) {
            ub = m2;
            m2 = m1;
            v2 = v1;
            m1 = ub - (ub - lb) / phi;
            v1 = f(m1);
        } else {
            lb = m1;
            m1 = m2;
            v1 = v2;
            m2 = lb + (ub - lb) / phi;
            v2 = f(m2);
        }
    }
    return lb;
}

const double PI = acos(-1);

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int N;
    cin >> N;
    vector<double> r(N);
    for (auto& x : r) cin >> x;

    double ans = 0;
    rep(S, 1, 1 << N) {
        vector<int> idx;
        rep(i, 0, N) if (S >> i & 1) idx.push_back(i);
        if (idx.size() <= 2) continue;

        auto f = [&](double lam) {
            double sumarea = 0;
            double sumtheta = 0;
            rep(i, 0, idx.size()) {
                double theta =
                    acos(2. * lam / (r[idx[i]] * r[idx[(i + 1) % idx.size()]]));
                sumarea +=
                    0.5 * r[idx[i]] * r[idx[(i + 1) % idx.size()]] * sin(theta);
                sumtheta += theta;
            }
            return sumarea - lam * (sumtheta - 2 * PI);
        };

        do {
            double x = 1e7;
            rep(i, 0, idx.size())
                chmin(x, 0.5 * r[idx[i]] * r[idx[(i + 1) % idx.size()]]);
            double lam = golden_section_search(f, -x, x, 100);
            chmax(ans, f(lam));
        } while (next_permutation(all(idx)));
    }
    cout << ans << endl;
}
accuracy: 0.7575757575757576
time_ms: 2400
memory_kb: 4196
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double EPS = 1e-10;  // to be set appropriately
const double INF = 1<<29;
const double PI = 3.141592653589793238462643383279502884L;

int main() {
    auto solve = [](const vector<double> &r) -> double {
        int K = (int)r.size();
        if (K < 3) return 0;
        
        // binary search
        double low = -INF, high = INF, sum_theta = 0;
        vector<double> theta(K);
        for (int iter = 0; iter < 100; ++iter) {
            double lambda = (low + high) / 2;
            sum_theta = 0;
            for (int i = 0; i < K; ++i) {
                double c = lambda / r[i] / r[(i+1)%K];
                chmin(c, 1.0 - EPS), chmax(c, -1.0 + EPS);
                theta[i] = acos(c);
                sum_theta += theta[i];
            }
            if (sum_theta < PI*2) high = lambda;
            else low = lambda;
        }

        // calc area
        double res = 0;
        for (int i = 0; i < K; ++i) res += r[i] * r[(i+1)%K] * sin(theta[i]) / 2;
        return res;
    };
    
    int N;
    cin >> N;
    vector<double> R(N);
    for (int i = 0; i < N; ++i) cin >> R[i];
    sort(R.begin(), R.end());
    
    double res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<double> r;
        for (int i = 0; i < N; ++i) if (bit & (1 << i)) r.push_back(R[i]);
        do {
            chmax(res, solve(r));
        } while (next_permutation(r.begin(), r.end()));
    }
    cout << fixed << setprecision(10) << res << endl;
}
accuracy: 1
time_ms: 1930
memory_kb: 4148
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double EPS = 1e-10;  // to be set appropriately
const double PI = 3.141592653589793238462643383279502884L;

int main() {
    auto solve = [](const vector<double> &r) -> double {
        int K = (int)r.size();
        if (K < 3) return 0;
        
        // binary search
        double low = 0, high = PI, sum_theta = 0.0;
        vector<double> theta(K);
        for (int iter = 0; iter < 100; ++iter) {
            double x = (low + high) / 2;
            sum_theta = theta[0] = x;
            for (int i = 1; i < K; ++i) {
                double c = r[0] * r[1] / r[i] / r[(i+1)%K] * cos(x);
                chmin(c, 1.0 - EPS), chmax(c, -1.0 + EPS);
                theta[i] = acos(c);
                sum_theta += theta[i];
            }
            if (sum_theta > PI*2) high = x;
            else low = x;
        }
        
        // check validity
        if (abs(sum_theta - PI*2) > EPS) return 0;
            
        // calc area
        double res = 0;
        for (int i = 0; i < K; ++i) res += r[i] * r[(i+1)%K] * sin(theta[i]) / 2;
        return res;
    };
    
    int N;
    cin >> N;
    vector<double> R(N);
    for (int i = 0; i < N; ++i) cin >> R[i];
    sort(R.begin(), R.end());
    
    double res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<double> r;
        for (int i = 0; i < N; ++i) if (bit & (1 << i)) r.push_back(R[i]);
        do {
            chmax(res, solve(r));
        } while (next_permutation(r.begin(), r.end()));
    }
    cout << fixed << setprecision(10) << res << endl;
}
accuracy: 1
time_ms: 1290
memory_kb: 4052
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using pint = pair<int, int>;
using pll = pair<long long, long long>;

#define REP(i, n) for (long long i = 0; i < (long long)(n); ++i)
#define REP2(i, a, b) for (long long i = a; i < (long long)(b); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s; }
template<class T> ostream& operator << (ostream &s, multiset<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s; }


const double EPS = 1e-10;  // to be set appropriately
const double PI = 3.141592653589793238462643383279502884L;

int main() {
    int N;
    cin >> N;
    vector<double> R(N);
    for (int i = 0; i < N; ++i) cin >> R[i];
    sort(R.begin(), R.end());
    
    auto solve = [](const vector<double> &r) -> double {
        int K = (int)r.size();
        if (K < 3) return 0;
        
        // binary search
        double low = 0, high = PI;
        vector<double> theta(K);
        for (int iter = 0; iter < 100; ++iter) {
            double x = (low + high) / 2;
            theta[0] = x;
            double sum_theta = x;
            for (int i = 1; i < K; ++i) {
                double c = r[0] * r[1] / r[i] / r[(i+1)%K] * cos(x);
                chmin(c, 1.0 - EPS), chmax(c, -1.0 + EPS);
                theta[i] = acos(c);
                sum_theta += theta[i];
            }
            if (sum_theta > PI*2) high = x;
            else low = x;
        }
            
        double res = 0;
        for (int i = 0; i < K; ++i) res += r[i] * r[(i+1)%K] * sin(theta[i]) / 2;
        
        //cout << "------" << endl; COUT(r); COUT(theta); COUT(res);

        
        return res;
    };
    
    double res = 0;
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<double> r;
        for (int i = 0; i < N; ++i) if (bit & (1 << i)) r.push_back(R[i]);
        do {
            chmax(res, solve(r));
        } while (next_permutation(r.begin(), r.end()));
    }
    
    cout << fixed << setprecision(10) << res << endl;
}
accuracy: 0.6060606060606061
time_ms: 130
memory_kb: 4052
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long double db;
const db pi=acos(-1);
db ans,a[10],p[10];int n,r[10],c[10];
int main(){
	scanf("%d",&n);for(int i=0;i<n;i++)scanf("%d",&r[i]);
	sort(r,r+n,greater<int>());
	for(int i=n;i>2;i--){
		for(int j=0;j<i;j++)c[j]=r[j];
		do{
			p[0]=c[0]*c[i-1];db mn=p[0];
			for(int j=1;j<i;j++)p[j]=c[j-1]*c[j],mn=min(mn,p[j]);
			db l=-mn,r=mn,s=0;
			while(r-l>1e-8){
				db md=(l+r)*0.5;s=0;
				for(int j=0;j<i;j++)s+=acos(md/p[j]);
				if(s>2*pi)l=md;else r=md;
			}
			db res=0;
			for(int j=0;j<i;j++)res+=p[j]*sin(acos(l/p[j]));
			if(fabs(s-2*pi)<1e-4)ans=max(ans,res);
		}while(prev_permutation(c+1,c+i));
	}
	printf("%.10Lf",ans*0.5);
}
accuracy: 1
time_ms: 130
memory_kb: 3604
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long double db;
const db pi=acos(-1),eps=1e-6;
db ans,a[10],p[10];int n,r[10],c[10];
int main(){
	scanf("%d",&n);for(int i=0;i<n;i++)scanf("%d",&r[i]);
	sort(r,r+n,greater<int>());
	for(int i=n;i>2;i--){
		for(int j=0;j<i;j++)c[j]=r[j];
		do{
			p[0]=c[0]*c[i-1];db mn=p[0];
			for(int j=1;j<i;j++)p[j]=c[j-1]*c[j],mn=min(mn,p[j]);
			db l=-mn,r=mn,s=0;
			while(r-l>eps){
				db md=(l+r)*0.5;s=0;
				for(int j=0;j<i;j++)s+=acos(md/p[j]);
				if(s>2*pi)l=md;else r=md;
			}
			db res=0;
			for(int j=0;j<i;j++)res+=p[j]*sin(acos(l/p[j]));
			if(fabs(s-2*pi)<eps)ans=max(ans,res);
		}while(prev_permutation(c+1,c+i));
	}
	printf("%.10Lf",ans*0.5);
}
accuracy: 0.9696969696969697
time_ms: 90
memory_kb: 4004
final_rank: 14

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long double db;
const db pi=acos(-1),eps=1e-8;
db ans,a[10],p[10];int n,r[10],c[10];
int main(){
	scanf("%d",&n);for(int i=0;i<n;i++)scanf("%d",&r[i]);
	sort(r,r+n,greater<int>());
	for(int i=n;i>2;i--){
		for(int j=0;j<i;j++)c[j]=r[j];
		do{
			p[0]=c[0]*c[i-1];db mx=0;
			for(int j=1;j<i;j++)p[j]=c[j-1]*c[j],mx=max(mx,p[j]);
			db l=-mx,r=mx;
			while(r-l>eps){
				db md=(l+r)*0.5,s=0;
				for(int j=0;j<i;j++)
					s+=acos(md/p[j]);
				if(s>2*pi)l=md;else r=md;
			}
			db res=0;
			for(int j=0;j<i;j++)res+=p[j]*sin(acos(l/p[j]));
			ans=max(ans,res);
		}while(prev_permutation(c+1,c+i));
	}
	printf("%.10Lf",ans*0.5);
}
accuracy: 0.6060606060606061
time_ms: 20
memory_kb: 4004
final_rank: 19

code_snippet: #include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for (int i=(a);i<=(n);i++)
#define per(i,a,n) for (int i=(n);i>=(a);i--)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
using db = long double;
const db PI = acosl(-1.0);
int n, r[8];

int main() {
#ifdef Asuka
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
	cin >> n;
	rep(i, 0, n - 1) cin >> r[i];
	db ans = 0;

	rep(s, 0, (1 << n) - 1) if (__builtin_popcount(s) >= 3) {
		vector<int> a, p;
		rep(i, 0, n - 1) if (s >> i & 1) a.pb(r[i]), p.pb(SZ(p));
		int m = SZ(p);

		do {
			vector<int> w;
			rep(i, 0, m - 1) w.pb(a[p[i]] * a[p[(i + 1) % m]]);
			sort(all(w));
			reverse(all(w));
			db l = 0, r = PI;

			rep(_, 1, 30) {
				db md = (l + r) * db(0.5), sm = 0;
				rep(i, 0, m - 1) {
					db o = cosl(md) * db(w[0]) / db(w[i]);

					if (o < -1) {
						sm = 100;
						break;
					}

					if (o > 1) {
						sm = -100;
					}

					sm += acosl(cosl(md) * db(w[0]) / db(w[i]));
				}

				if (sm >= PI * 2) {
					r = md;
				} else {
					l = md;
				}
			}

			// cout << l << ' ' << r << '\n';

			db res = 0, sm = 0;
			rep(i, 0, m - 1) res += sinl(acosl(cosl(l) * db(w[0]) / db(w[i]))) * db(w[i]);
			// rep(i, 0, m - 1) sm += acosl(cosl(l) * db(w[0]) / db(w[i]));
			ans = max(ans, res);
		} while (next_permutation(all(p)));
	}

	ans /= 2;
	cout << fixed << setprecision(20) << ans << '\n';
	return 0;
}
accuracy: 1
time_ms: 2170
memory_kb: 3940
final_rank: 6

code_snippet: #include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for (int i=(a);i<=(n);i++)
#define per(i,a,n) for (int i=(n);i>=(a);i--)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
using db = long double;
const db PI = acosl(-1.0);
int n, r[8];

int main() {
#ifdef Asuka
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
	cin >> n;
	rep(i, 0, n - 1) cin >> r[i];
	db ans = 0;

	rep(s, 0, (1 << n) - 1) if (__builtin_popcount(s) >= 3) {
		vector<int> a, p;
		rep(i, 0, n - 1) if (s >> i & 1) a.pb(r[i]), p.pb(SZ(p));
		int m = SZ(p);

		do {
			vector<int> w;
			rep(i, 0, m - 1) w.pb(a[p[i]] * a[p[(i + 1) % m]]);
			if (__builtin_popcount(s) > 3) {
				sort(all(w));
				reverse(all(w));
			}
			db l = 0, r = PI;

			rep(_, 1, 50) {
				db md = (l + r) * db(0.5), sm = 0;
				rep(i, 0, m - 1) sm += acosl(cosl(md) * db(w[0]) / db(w[i]));

				if (sm >= PI * 2) {
					r = md;
				} else {
					l = md;
				}
			}

			// cout << l << ' ' << r << '\n';

			db res = 0, sm = 0;
			rep(i, 0, m - 1) res += sinl(acosl(cosl(l) * db(w[0]) / db(w[i]))) * db(w[i]);
			// rep(i, 0, m - 1) sm += acosl(cosl(l) * db(w[0]) / db(w[i]));
			ans = max(ans, res);
		} while (next_permutation(all(p)));
	}

	ans /= 2;
	cout << fixed << setprecision(20) << ans << '\n';
	return 0;
}
accuracy: 1
time_ms: 3370
memory_kb: 3936
final_rank: 9

code_snippet: #include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for (int i=(a);i<=(n);i++)
#define per(i,a,n) for (int i=(n);i>=(a);i--)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define lowbit(i) ((i)&(-i))
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
using namespace std;
using db = long double;
const db PI = acosl(-1.0);
int n, r[8];

int main() {
#ifdef Asuka
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
	cin >> n;
	rep(i, 0, n - 1) cin >> r[i];
	db ans = 0;

	rep(s, 0, (1 << n) - 1) if (__builtin_popcount(s) >= 3) {
		vector<int> a, p, w;
		rep(i, 0, n - 1) if (s >> i & 1) a.pb(r[i]), p.pb(SZ(p));
		int m = SZ(p);

		do {
			w.clear();
			rep(i, 0, m - 1) w.pb(a[p[i]] * a[p[(i + 1) % m]]);
			db l = 0, r = PI;

			rep(_, 1, 50) {
				db md = (l + r) * db(0.5), sm = 0;

				// cout << md << '\n';
				// rep(i, 0, m - 1) cout << acosl(cosl(md) * w[0] / w[i]) << ' ';
				// cout << '\n';

				rep(i, 0, m - 1) sm += acosl(cosl(md) * db(w[0]) / db(w[i]));

				if (sm >= PI * 2) {
					r = md;
				} else {
					l = md;
				}
			}

			db res = 0, sm = 0;
			rep(i, 0, m - 1) res += sinl(acosl(cosl(l) * db(w[0]) / db(w[i]))) * db(w[i]);
			ans = max(ans, res);

			// if (res > 3000) {
			// 	cout << "ee\n";
			// 	rep(i, 0, m - 1) cout << w[i] << ' ';
			// 	cout << '\n';
			// 	rep(i, 0, m - 1) cout << a[i] << ' ';
			// 	cout << '\n';
			// 	rep(i, 0, m - 1) cout << sinl(acosl(cosl(l) * db(w[0]) / db(w[i]))) * db(w[i]) << ' ';
			// 	cout << '\n';
			// }

		} while (next_permutation(all(p)));
	}

	ans /= 2;
	cout << fixed << setprecision(20) << ans << '\n';
	return 0;
}
accuracy: 0.6060606060606061
time_ms: 330
memory_kb: 3944
final_rank: 18

code_snippet: #include <bits/stdc++.h>
#define rep(i, l, r) for(int i = (l); i <= (r); i++)
#define per(i, r, l) for(int i = (r); i >= (l); i--)
#define mem(a, b) memset(a, b, sizeof a)
#define For(i, l, r) for(int i = (l), i##e = (r); i < i##e; i++)
#define pb push_back
#define eb emplace_back
#define SZ(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const double PI = acos(-1);

int n;
double r[10], a[10];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    For(i, 0, n) cin >> r[i];
    sort(r, r + n, greater<>());
    mt19937 gen;
    uniform_real_distribution<> dis(-1, 1);
    double ans = 0;
    for(; n >= 3; n--) {
        r[n] = r[0];
        do {
            rep(i, 0, n) a[i] = PI * 2 / n * i;
            double now = 0;
            auto calc = [](int i, int j) {
                return sin(a[j] - a[i]) * r[i] * r[j];
            };
            For(i, 0, n) now += calc(i, i + 1);
            for(double t = PI / 2; t >= 1e-9; t *= 0.97) For(i, 1, n) {
                double ai = a[i], lst = calc(i - 1, i) + calc(i, i + 1);
                a[i] += t * dis(gen);
                if(a[i] <= a[i - 1] | a[i] >= a[i + 1]) { a[i] = ai; continue; }
                double d = calc(i - 1, i) + calc(i, i + 1) - lst;
                if(d > 0) now += d; else a[i] = ai;
            }
            ans = max(ans, now);
        } while(prev_permutation(r + 1, r + n));
    }
    cout << setprecision(10) << fixed << ans / 2 << '\n';
}
accuracy: 1
time_ms: 1210
memory_kb: 4012
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

// base
namespace geometry {
  using namespace std;
  using real_number = long double;

  const real_number PI = acosl(-1);

  inline static real_number &eps() {
    static real_number EPS = 1e-10;
    return EPS;
  }

  static void set_eps(real_number EPS) {
    eps() = EPS;
  }

  inline int sign(real_number r) {
    set_eps(1e-10);
    if (r < -eps()) return -1;
    if (r > +eps()) return +1;
    return 0;
  }

  inline bool equals(real_number r1, real_number r2) {
    return sign(r1 - r2) == 0;
  }
}

// point
namespace geometry {
  using point = complex< real_number >;
  using points = vector< point >;

  istream &operator>>(istream &is, point &p) {
    real_number x, y;
    is >> x >> y;
    p = point(x, y);
    return is;
  }

  ostream &operator<<(ostream &os, const point &p) {
    return os << p.real() << " " << p.imag();
  }

  point operator*(const point &p, const real_number &k) {
    return point(p.real() * k, p.imag() * k);
  }

  point rotate(const real_number &theta, const point &p) {
    return point(cos(theta) * p.real() + sin(-theta) * p.imag(),
                 sin(theta) * p.real() + cos(-theta) * p.imag());
  }

  bool equals(const point &a, const point &b) {
    return equals(a.real(), b.real()) and equals(a.imag(), b.imag());
  }
}

using geometry::operator>>;
using geometry::operator<<;

// product
namespace geometry {
  real_number cross(const point &a, const point &b) {
    return a.real() * b.imag() - a.imag() * b.real();
  }

  real_number dot(const point &a, const point &b) {
    return a.real() * b.real() + a.imag() * b.imag();
  }
}
using namespace geometry;

real_number calc(const vector< real_number > &rs) {
  // n := rs.size(), 3 \leq n
  // maximize \sum{ rs[i] * rs[(i + 1) % n] * sin(ts[i]) }
  //            s.t. \sum{ ts[i] } - 2PI = 0
  //
  // f(ts[0], ts[1], ..., ts[n-1]) = \sum{ rs[i] * rs[(i+1)%n] * sin(ts[i]) }
  // g(ts[0], ts[1], ..., ts[n-1]) = \sum{ ts[i] } - 2PI
  //
  // Lagrange function L :=
  // L(ts[0], ts[1], ..., ts[n-1]) = f - \lambda g
  //                               = \sum{ rs[i] * rs[(i+1)%n] * sin(ts[i]) } - \lamdba (\sum{ ts[i] } - 2PI )
  //
  // rs[0] * rs[1] * cos(ts[0]) - \lamdba
  //   = ...
  //   = rs[i] * rs[(i+1)%n] * cos(ts[i]) - \lamdba
  //   = ...
  //   = 0 
  //
  // \lamdba = rs[0] * rs[1] * cos(ts[0])
  // => rs[i] * rs[(i+1)%n] * cos(ts[i]) - rs[0] * rs[1] * cos(ts[0]) = 0
  // => rs[i] * rs[(i+1)%n] * cos(ts[i]) = rs[0] * rs[1] * cos(ts[0])
  // => cos(ts[i]) = (rs[0] * rs[1])/(rs[i] * rs[(i+1)%n]) * cos(ts[0])
  //
  // as[i] := (rs[0] * rs[1]) / (rs[i] * rs[(i+1)%n])
  // ts[0] = m, ts[i] = acos(as[i] * cos(ts[0])), and \sum{ ts[i] } = 2PI
  // => binary search
  assert(rs.size() >= 3);
  int n = rs.size();

  auto make_ts = [&](real_number t0) {
    vector< real_number > ts;
    range(i, 0, n) {
      real_number a = (rs[0] * rs[1]) / (rs[i] * rs[(i+1)%n]);
      ts.emplace_back(acosl(clamp(a * cos(t0), real_number(-1), real_number(1))));
    }
    return ts;
  };
  real_number lb = 0, ub = PI;
  range(qi, 0, 200) {
    real_number m = (lb + ub) / 2;
    vector< real_number > ts = make_ts(m);
    real_number theta_sum = whole(accumulate, ts, real_number(0));

    if (theta_sum < 2 * PI) lb = m;
    else ub = m;
  }

  real_number S = 0;
  vector< real_number > ts = make_ts(lb);
  if (not equals(whole(accumulate, ts, real_number(0)), 2 * PI)) return S;

  range(i, 0, n) {
    S += rs[i] * rs[(i+1)%n] * sinl(ts[i]);
  }

  return S / 2;
}

void solve() {
  int n = input();
  vector< real_number > rs(n);
  cin >> rs;

  whole(sort, rs);

  real_number ans = 0;
  range(bit, 0, 1 << n) {
    vector< real_number > subset_r;
    range(i, 0, n) {
      if (~bit & (1 << i)) continue;
      subset_r.emplace_back(rs[i]);
    }

    if (subset_r.size() < 3) continue;

    do {
      chmax(ans, calc(subset_r));
    } while (next_permutation(subset_r.begin() + 1, subset_r.end()));
  }

  cout << ans << endl;
}

signed main() {
  solve();
}
accuracy: 1
time_ms: 1760
memory_kb: 3956
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

// base
namespace geometry {
  using namespace std;
  using real_number = long double;

  const real_number PI = acosl(-1);

  inline static real_number &eps() {
    static real_number EPS = 1e-10;
    return EPS;
  }

  static void set_eps(real_number EPS) {
    eps() = EPS;
  }

  inline int sign(real_number r) {
    set_eps(1e-10);
    if (r < -eps()) return -1;
    if (r > +eps()) return +1;
    return 0;
  }

  inline bool equals(real_number r1, real_number r2) {
    return sign(r1 - r2) == 0;
  }
}

// point
namespace geometry {
  using point = complex< real_number >;
  using points = vector< point >;

  istream &operator>>(istream &is, point &p) {
    real_number x, y;
    is >> x >> y;
    p = point(x, y);
    return is;
  }

  ostream &operator<<(ostream &os, const point &p) {
    return os << p.real() << " " << p.imag();
  }

  point operator*(const point &p, const real_number &k) {
    return point(p.real() * k, p.imag() * k);
  }

  point rotate(const real_number &theta, const point &p) {
    return point(cos(theta) * p.real() + sin(-theta) * p.imag(),
                 sin(theta) * p.real() + cos(-theta) * p.imag());
  }

  bool equals(const point &a, const point &b) {
    return equals(a.real(), b.real()) and equals(a.imag(), b.imag());
  }
}

using geometry::operator>>;
using geometry::operator<<;

// product
namespace geometry {
  real_number cross(const point &a, const point &b) {
    return a.real() * b.imag() - a.imag() * b.real();
  }

  real_number dot(const point &a, const point &b) {
    return a.real() * b.real() + a.imag() * b.imag();
  }
}
using namespace geometry;

real_number calc(const vector< real_number > &rs) {
  // n := rs.size(), 3 \leq n
  // maximize \sum{ rs[i] * rs[(i + 1) % n] * sin(ts[i]) }
  //            s.t. \sum{ ts[i] } - 2PI = 0
  //
  // f(ts[0], ts[1], ..., ts[n-1]) = \sum{ rs[i] * rs[(i+1)%n] * sin(ts[i]) }
  // g(ts[0], ts[1], ..., ts[n-1]) = \sum{ ts[i] } - 2PI
  //
  // Lagrange function L :=
  // L(ts[0], ts[1], ..., ts[n-1]) = f - \lambda g
  //                               = \sum{ rs[i] * rs[(i+1)%n] * sin(ts[i]) } - \lamdba (\sum{ ts[i] } - 2PI )
  //
  // rs[0] * rs[1] * cos(ts[0]) - \lamdba
  //   = ...
  //   = rs[i] * rs[(i+1)%n] * cos(ts[i]) - \lamdba
  //   = ...
  //   = 0 
  //
  // \lamdba = rs[0] * rs[1] * cos(ts[0])
  // => rs[i] * rs[(i+1)%n] * cos(ts[i]) - rs[0] * rs[1] * cos(ts[0]) = 0
  // => rs[i] * rs[(i+1)%n] * cos(ts[i]) = rs[0] * rs[1] * cos(ts[0])
  // => cos(ts[i]) = (rs[0] * rs[1])/(rs[i] * rs[(i+1)%n]) * cos(ts[0])
  //
  // as[i] := (rs[0] * rs[1]) / (rs[i] * rs[(i+1)%n])
  // ts[0] = m, ts[i] = acos(as[i] * cos(ts[0])), and \sum{ ts[i] } = 2PI
  // => binary search
  assert(rs.size() >= 3);
  int n = rs.size();

  real_number lb = 0, ub = PI;
  range(qi, 0, 100) {
    real_number m = (lb + ub) / 2;
    vector< real_number > ts;
    range(i, 0, n) {
      real_number a = (rs[0] * rs[1]) / (rs[i] * rs[(i+1)%n]);
      ts.emplace_back(acosl(clamp(a * cos(m), real_number(-1), real_number(1))));
    }

    real_number theta_sum = whole(accumulate, ts, real_number(0));
    if (theta_sum < 2 * PI) lb = m;
    else ub = m;
  }

  real_number t0 = lb;
  real_number S = 0;
  range(i, 0, n) {
    real_number a = (rs[0] * rs[1]) / (rs[i] * rs[(i+1)%n]);
    real_number theta = acosl(clamp(a * cos(t0), real_number(-1), real_number(1)));
    S += rs[i] * rs[(i+1)%n] * sinl(theta);
  }

  return S / 2;
}

void solve() {
  int n = input();
  vector< real_number > rs(n);
  cin >> rs;

  whole(sort, rs);

  real_number ans = 0;
  range(bit, 0, 1 << n) {
    vector< real_number > subset_r;
    range(i, 0, n) {
      if (~bit & (1 << i)) continue;
      subset_r.emplace_back(rs[i]);
    }

    if (subset_r.size() < 3) continue;

    do {
      chmax(ans, calc(subset_r));
    } while (next_permutation(subset_r.begin() + 1, subset_r.end()));
  }

  cout << ans << endl;
}

signed main() {
  solve();
}
accuracy: 0.6060606060606061
time_ms: 110
memory_kb: 3960
final_rank: 17

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define drep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define popcount __builtin_popcount
#define next __next
#define prev __prev

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

template <class T>
bool chmin(T &a, const T &b) {
  if (a <= b) return false;
  a = b;
  return true;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a >= b) return false;
  a = b;
  return true;
}

template <class T>
using MaxHeap = priority_queue<T>;

template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &e : v) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------------ ACL --------------------

// #include <atcoder/modint>
// constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
// using mint = atcoder::static_modint<MOD>;
// ostream &operator<<(ostream &os, const mint &v) {
//   return os << v.val();
// }

// ------------ End of template --------------

#define endl "\n"
using ll = long long;
using pii = pair<int, int>;

const bool multitest = false;

void solve() {
  int N;
  cin >> N;
  vector<double> rad(N);
  cin >> rad;

  double ans = 0.0;
  for (int S = 0; S < (1 << N); S++) {
    int M = popcount(S);
    if (M < 3) continue;
    vector<int> perm;
    for (int i = 0; i < N; i++) {
      if ((S >> i) & 1) perm.push_back(i);
    }
    do {
      vector<double> R(M);
      for (int i = 0; i < M; i++) { R[i] = rad[perm[i]]; }
      vector<double> tmp;
      auto check = [&](double X, bool save = false) {
        vector<double> arg;
        arg.push_back(0.0);
        arg.push_back(X);
        for (int i = 2; i <= M; i++) {
          double k = R[i - 2] * cos(arg[i - 1] - arg[i - 2]);
          if (R[i % M] < k) return true;
          if (k < -R[i % M]) return false;
          arg.push_back(arg.back() + acos(k / R[i % M]));
        }
        if (arg.back() > 2.0 * M_PI - eps) return false;
        if (save) tmp = arg;
        return true;
      };
      double l = 0.0, r = M_PI;
      for (int i = 0; i < 30; i++) {
        double mid = (l + r) / 2.0;
        if (check(mid))
          l = mid;
        else
          r = mid;
      }

      check(l, true);
      if (tmp.size() == M + 1 && tmp.back() < 2.0 * M_PI) {
        double area = 0.0;
        for (int i = 1; i <= M; i++) {
          area += R[i % M] * R[i - 1] * sin(tmp[i] - tmp[i - 1]) * 0.5;
        }
        dmp(area, tmp);
        chmax(ans, area);
      }
    } while (next_permutation(perm.begin() + 1, perm.end()));
  }

  cout << ans << endl;

  return;
}

int main() {
  fastio();
  if (!multitest) {
    solve();
  } else {
    cerr << "[Warning] Multi testcase mode on" << endl;
    int t;
    cin >> t;
    while (t--) solve();
  }
  return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 4120
final_rank: 3

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define drep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)

#define popcount __builtin_popcount
#define next __next
#define prev __prev

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

template <class T>
bool chmin(T &a, const T &b) {
  if (a <= b) return false;
  a = b;
  return true;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a >= b) return false;
  a = b;
  return true;
}

template <class T>
using MaxHeap = priority_queue<T>;

template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &e : v) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------------ ACL --------------------

// #include <atcoder/modint>
// constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
// using mint = atcoder::static_modint<MOD>;
// ostream &operator<<(ostream &os, const mint &v) {
//   return os << v.val();
// }

// ------------ End of template --------------

#define endl "\n"
using ll = long long;
using pii = pair<int, int>;

const bool multitest = false;

void solve() {
  int N;
  cin >> N;
  vector<double> rad(N);
  cin >> rad;

  double ans = 0.0;
  for (int S = 0; S < (1 << N); S++) {
    int M = popcount(S);
    if (M < 3) continue;
    vector<int> perm;
    for (int i = 0; i < N; i++) {
      if ((S >> i) & 1) perm.push_back(i);
    }
    do {
      vector<double> R(M);
      for (int i = 0; i < M; i++) { R[i] = rad[perm[i]]; }
      vector<double> tmp;
      auto check = [&](double X, bool save = false) {
        vector<double> arg;
        arg.push_back(0.0);
        arg.push_back(X);
        for (int i = 2; i <= M; i++) {
          double k = R[i - 2] * cos(arg[i - 1] - arg[i - 2]);
          if (R[i % M] < k) return true;
          if (k < -R[i % M]) return false;
          dmp(k / R[i % M]);
          arg.push_back(arg.back() + acos(k / R[i % M]));
        }
        if (arg.back() > 2.0 * M_PI - eps) return false;
        if (save) tmp = arg;
        return true;
      };
      double l = 0.0, r = M_PI;
      for (int i = 0; i < 30; i++) {
        double mid = (l + r) / 2.0;
        if (check(mid))
          l = mid;
        else
          r = mid;
      }

      check(l, true);
      if (tmp.size() == M + 1 && tmp.back() < 2.0 * M_PI) {
        double area = 0.0;
        for (int i = 1; i <= M; i++) {
          area += R[i % M] * R[i - 1] * sin(tmp[i] - tmp[i - 1]) * 0.5;
        }
        dmp(area, tmp);
        chmax(ans, area);
      }
    } while (next_permutation(perm.begin() + 1, perm.end()));
  }

  cout << ans << endl;

  return;
}

int main() {
  fastio();
  if (!multitest) {
    solve();
  } else {
    cerr << "[Warning] Multi testcase mode on" << endl;
    int t;
    cin >> t;
    while (t--) solve();
  }
  return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 4116
final_rank: 2

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define drep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)

#define popcount __builtin_popcount
#define next __next
#define prev __prev

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

template <class T>
bool chmin(T &a, const T &b) {
  if (a <= b) return false;
  a = b;
  return true;
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a >= b) return false;
  a = b;
  return true;
}

template <class T>
using MaxHeap = priority_queue<T>;

template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (const T &e : v) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------------ ACL --------------------

// #include <atcoder/modint>
// constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
// using mint = atcoder::static_modint<MOD>;
// ostream &operator<<(ostream &os, const mint &v) {
//   return os << v.val();
// }

// ------------ End of template --------------

#define endl "\n"
using ll = long long;
using pii = pair<int, int>;

const bool multitest = false;

void solve() {
  int N;
  cin >> N;
  vector<double> rad(N);
  cin >> rad;

  double ans = 0.0;
  for (int S = 0; S < (1 << N); S++) {
    int M = popcount(S);
    if (M < 3) continue;
    vector<int> perm;
    for (int i = 0; i < N; i++) {
      if ((S >> i) & 1) perm.push_back(i);
    }
    do {
      vector<double> R(M);
      for (int i = 0; i < M; i++) { R[i] = rad[perm[i]]; }
      vector<double> tmp;
      auto check = [&](double X, bool save = false) {
        vector<double> arg;
        arg.push_back(0.0);
        arg.push_back(X);
        for (int i = 2; i <= M; i++) {
          double k = R[i - 2] * cos(arg[i - 1] - arg[i - 2]);
          // if (R[i % M] < k) return false;
          // if (k < -R[i % M]) return true;
          // dmp(k / R[i % M]);
          // assert(k / R[i % M] <= 1.0 && k / R[i % M] >= -1.0);
          arg.push_back(arg.back() + acos(k / R[i % M]));
        }
        if (arg.back() > 2.0 * M_PI - eps) return false;
        if (save) tmp = arg;
        return true;
      };
      double l = 0.0, r = M_PI;
      for (int i = 0; i < 30; i++) {
        double mid = (l + r) / 2.0;
        if (check(mid))
          l = mid;
        else
          r = mid;
      }

      check(l, true);
      if (tmp.size() == M + 1 && tmp.back() < 2.0 * M_PI) {
        double area = 0.0;
        for (int i = 1; i <= M; i++) {
          area += R[i % M] * R[i - 1] * sin(tmp[i] - tmp[i - 1]) * 0.5;
        }
        dmp(area, tmp);
        chmax(ans, area);
      }
    } while (next_permutation(perm.begin() + 1, perm.end()));
  }

  cout << ans << endl;

  return;
}

int main() {
  fastio();
  if (!multitest) {
    solve();
  } else {
    cerr << "[Warning] Multi testcase mode on" << endl;
    int t;
    cin >> t;
    while (t--) solve();
  }
  return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 4164
final_rank: 7