Problem:
Jewelry Size
Figure E.1. Jewelry
She came up with a new jewelry design. The design uses two parts: a hollow circlet and a
convex polygonal component. The design can be customized by specifying the edge lengths of
the polygon, which should be multiples of a unit length, so that customers can embed memorial
numbers in the jewelry. Note that there can be many different polygons with edges of the
specified lengths. Among them, one with a circumscribed circle, that is, a circle that passes
through all of its vertices, is chosen so that the polygonal component can be firmly anchored to the circlet
Figure E.2. (a) A pentagon with a circumscribed circle; (b) A pentagon with no circumscribed circle; (c) Another pentagon with no circumscribed circle
For example, Figure E.2(a) has a pentagon with its edge lengths of 3, 1, 6, 1, and 7 units, meaning March 16th and 17th. The radius of the circle is approximately 3.544 units. Figures E.2(b) and E.2(c) show pentagons with the same edge lengths but neither of them has a circumscribed
circle.
To commercialize the jewelry, she needs to be able to compute the radius of the circumscribed
circle from specified edge lengths. Can you help her by writing a program for this task?
Input
The input consists of a single test case of the following format.
$n$
$x_1$ ... $x_n$
$n$ is an integer that indicates the number of edges ($3 \leq n \leq 1000$). $x_k$ ($k = 1,..., n$) is an integer that indicates the length of the $k$-th edge ($1 \leq x_k \leq 6000$).
You may assume the existence of one or more polygons with the specified edge lengths. You can
prove that one of such polygons has a circumscribed circle.
Output
Output the minimum radius of a circumscribed circle of a polygon with the specified edge
lengths. Absolute/relative error of the output should be within $10^{-7}$.
Sample Input 1
5
3 1 6 1 7
Sample Output 1
3.54440435
Sample Input 2
3
500 300 400
Sample Output 2
250.0
Sample Input 3
6
2000 3000 4000 2000 3000 4000
Sample Output 3
3037.33679126
Sample Input 4
10
602 67 67 67 67 67 67 67 67 67
Sample Output 4
3003.13981697
Sample Input 5
3
6000 6000 1
Sample Output 5
3000.00001042

Submitted solutions:

code_snippet: #include<bits/extc++.h>
#define rep(i,n) for(int i = 0; i<(n); i++)
#define all(a) begin(i),end(i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 998244353;
const int inf = (1<<30);
const ll INF = (1ull<<62);
const int dx[8] = {1,0,-1,0,1,1,-1,-1};
const int dy[8] = {0,1,0,-1,1,-1,1,-1};
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 chmix(T1 &a, T2 b){return a > b && (a = b, true);}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    sort(x.begin(), x.end(), greater<>());

    long double l = *max_element(x.begin(), x.end()) / 2.0, r = 1e9, sum;
    for (int i = 0; i < 1000; i++){
        long double mid = (l + r) / 2;
        sum = 0;
        for (int j = 0; j < n; j++){
            sum += 2.0 * mid * asin(x[j] / mid / 2.0);
        }
        if (sum < 2.0 * M_PI * mid) r = mid;
        else l = mid;
    }
    long double res = l, res_v = sum;

    l = *max_element(x.begin(), x.end()) / 2.0, r = 1e9;
    for (int i = 0; i < 1000; i++){
        long double mid = (l + r) / 2;
        sum = 0;
        long double f = 2 * mid * asin(x[0] / mid / 2.0);
        for (int j = 1; j < n; j++){
            sum += 2.0 * mid * asin(x[j] / mid / 2.0);
        }
        if (f < sum) r = mid;
        else l = mid;
        sum += 2.0 * M_PI * mid - f;
    }

    if (abs(sum - 2.0 * M_PI * l) < abs(res_v - 2.0 * M_PI * res)) swap(res, l);

    cout << res << endl;
}
accuracy: 1
time_ms: 30
memory_kb: 3612
final_rank: 3

code_snippet: #include<bits/extc++.h>
#define rep(i,n) for(int i = 0; i<(n); i++)
#define all(a) begin(i),end(i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 998244353;
const int inf = (1<<30);
const ll INF = (1ull<<62);
const int dx[8] = {1,0,-1,0,1,1,-1,-1};
const int dy[8] = {0,1,0,-1,1,-1,1,-1};
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 chmix(T1 &a, T2 b){return a > b && (a = b, true);}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout.setf(ios_base::fixed);
    cout.precision(12);
    int n;
    cin >> n;
    vector<int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];
    sort(x.begin(), x.end(), greater<>());

    long double l = *max_element(x.begin(), x.end()) / 2.0, r = 5000, sum;
    for (int i = 0; i < 1000; i++){
        long double mid = (l + r) / 2;
        sum = 0;
        for (int j = 0; j < n; j++){
            sum += 2.0 * mid * asin(x[j] / mid / 2.0);
        }
        if (sum < 2.0 * M_PI * mid) r = mid;
        else l = mid;
    }
    long double res = l, res_v = sum;

    l = *max_element(x.begin(), x.end()) / 2.0, r = 5000;
    for (int i = 0; i < 1000; i++){
        long double mid = (l + r) / 2;
        sum = 0;
        long double f = 2 * mid * asin(x[0] / mid / 2.0);
        for (int j = 1; j < n; j++){
            sum += 2.0 * mid * asin(x[j] / mid / 2.0);
        }
        if (f < sum) r = mid;
        else l = mid;
        sum += 2.0 * M_PI * mid - f;
    }

    if (abs(sum - 2.0 * M_PI * l) < abs(res_v - 2.0 * M_PI * res)) swap(res, l);

    cout << res << endl;
}
accuracy: 0.046511627906976744
time_ms: 30
memory_kb: 3496
final_rank: 12

code_snippet: #include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <tuple>
#include <ranges>
namespace ranges = std::ranges;
namespace views = std::views;
// #include "Src/Number/IntegerDivision.hpp"


#include <cstdint>
#include <cstddef>

namespace zawa {

using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using i128 = __int128_t;

using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;

using usize = std::size_t;

} // namespace zawa

#include <cmath>
#include <functional>
#include <type_traits>

namespace zawa {

namespace internal {

template <class T>
T MidPoint(T a, T b) {
    if (a > b) std::swap(a, b);
    return a + ((b - a) >> 1);
}

template <class T>
T Abs(T a, T b) {
    return (a >= b ? a - b : b - a);
}

} // namespace zawa::internal

template <class T, class Function>
T BinarySearch(T ok, T ng, const Function& f) {
    static_assert(std::is_integral_v<T>, "T must be integral type");
    static_assert(std::is_convertible_v<Function, std::function<bool(T)>>, "f must be function bool(T)");
    while (internal::Abs(ok, ng) > 1) {
        T mid{ internal::MidPoint(ok, ng) };
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

template <class T, class Function>
T BinarySearch(T ok, T ng, const Function& f, u32 upperLimit) {
    static_assert(std::is_signed_v<T>, "T must be signed arithmetic type");
    static_assert(std::is_convertible_v<Function, std::function<bool(T)>>, "f must be function bool(T)");
    for (u32 _{} ; _ < upperLimit ; _++) {
        T mid{ (ok + ng) / (T)2 };
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

} // namespace zawa
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// #include "Src/Algebra/Group/AdditiveGroup.hpp"
// #include "Src/DataStructure/FenwickTree/FenwickTree.hpp"
// #include "Src/DataStructure/SegmentTree/SegmentTree.hpp"
using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
int N;
long double X[1000];
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cin >> N;
    for (int i = 0 ; i < N ; i++) std::cin >> X[i];
    long double min_r = 0;
    for (int i = 0 ; i < N ; i++) min_r = std::max(min_r, X[i] / 2);
    auto f = [&](long double r) -> bool {
        long double sum = 0;
        for (int i = 0 ; i < N ; i++) {
            long double val = 1 - (X[i]*X[i])/(2.0l*r*r);
            sum += acosl(val);
        }
        // std::cout << r << ' ' << sum << std::endl;
        return sum >= 2 * acosl(-1);
    };
    auto g = [&](long double r) -> bool {
        auto max = ranges::max_element(X, X + N) - X;
        long double sum1 = 0, sum2 = 0;
        for (int i = 0 ; i < N ; i++) {
            long double val = 1 - (X[i]*X[i])/(2.0l*r*r);
            if (i == max) {
                sum1 += acosl(val);
            }
            else {
                sum2 += acosl(val);
            }
        }
        return sum2 <= sum1;
    };
    const auto a1 = BinarySearch(min_r, (long double)1e7, f, 100);
    const auto a2 = BinarySearch(min_r, (long double)1e7, g, 100);
    // std::cout << a1 << ' ' << a2 << std::endl;
    std::cout << std::fixed << std::setprecision(9) << std::max(a1, a2) << '\n';
}
accuracy: 1
time_ms: 10
memory_kb: 3840
final_rank: 7

code_snippet: #include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define vec vector
#undef long
#define long long long
using ll = long;
void solve() {
	int n;
	cin >> n;
	vec<long> a(n);
	for (long &i : a)
		cin >> i;
	auto cal = [&](double vs) {
		double s = 0;
		for (long i : a)
			s += asin(i / (2. * vs));
		return s;
	};
	long max_a = *max_element(a.begin(), a.end());
	double ok = max_a / 2.0, ng = 1e10;
	if (cal(ok) >= M_PI) {
		rep(___, 10000) {
			double vs = (ok + ng) / 2;
			double s = cal(vs) - M_PI;
			if (s >= 0)
				ok = vs;
			else
				ng = vs;
		}
	} else {
		rep(___, 10000) {
			double vs = (ok + ng) / 2;
			double s = cal(vs) - 2 * asin(max_a / (2. * vs));
			if (s <= 0)
				ok = vs;
			else
				ng = vs;
		}
	}
	cout << fixed << setprecision(20) << ok << endl;
	return;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
}
accuracy: 1
time_ms: 50
memory_kb: 3988
final_rank: 9

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(a) begin(a),end(a)
#define rep(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
using ld=long double;
int main(){
	int n;
	cin>>n;
	ld pi=acos(-1);
	vector<ld>A(n);
	
	rep(i,0,n)cin>>A[i];
	// cerr<<"a";
	sort(A.begin(),A.end());
	ld ok=A.back()/2,ng=6000000;
	rep(o,0,500){
		ld sum=0;
		ld mid=(ok+ng)/2;
		rep(ii,0,n-1){
			int i=n-2-ii;
			ld theta=acos((2*mid*mid-A[i]*A[i])/(2*mid*mid));
			sum+=theta;
		}
		if(sum>2*pi){
			ok=mid;
			continue;
		}
		ld q=sqrt(2*mid*mid-2*mid*mid*cos(sum));
		// cerr<<mid<<" "<<q<<" "<<A.back()<<endl;
		if(q<A.back()){
			ok=mid;
		}else{
			ng=mid;
		}
	}
	cout<<fixed<<setprecision(15)<<ok<<endl;
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3952
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(a) begin(a),end(a)
#define rep(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
using ld=long double;
int main(){
	int n;
	cin>>n;
	ld pi=acos(-1);
	vector<ld>A(n);
	
	rep(i,0,n)cin>>A[i];
	sort(A.begin(),A.end());
	ld ok=A.back()/2,ng=6000000;
	rep(o,0,500){
		ld sum=0;
		ld mid=(ok+ng)/2;
		rep(i,0,n-1){
			ld theta=acos((2*mid*mid-A[i]*A[i])/(2*mid*mid));
			sum+=theta;
		}
		ld q=sqrt(2*mid*mid-2*mid*mid*cos(sum));
		// cerr<<mid<<" "<<q<<" "<<A.back()<<endl;
		if(q<A.back()){
			ok=mid;
		}else{
			ng=mid;
		}
	}
	cout<<fixed<<setprecision(15)<<ok<<endl;
	return 0;
}
accuracy: 0.046511627906976744
time_ms: 20
memory_kb: 3896
final_rank: 13

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

#define ll long long
#define elif else if
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int,int>


#define repname(a, b, c, d, e, ...) e
#define rep(...)                    repname(__VA_ARGS__, rep3, rep2, rep1, rep0)(__VA_ARGS__)
#define rep0(x)                     for (int rep_counter = 0; rep_counter < (x); ++rep_counter)
#define rep1(i, x)                  for (int i = 0; i < (x); ++i)
#define rep2(i, l, r)               for (int i = (l); i < (r); ++i)
#define rep3(i, l, r, c)            for (int i = (l); i < (r); i += (c))





struct ScalarInput {
    template<class T>
    operator T(){
        T ret;
        cin >> ret;
        return ret;
    }
};
struct VectorInput {
    size_t n;
    VectorInput(size_t n): n(n) {}
    template<class T>
    operator vector<T>(){
        vector<T> ret(n);
        for(T &x : ret) cin >> x;
        return ret;
    }
};
ScalarInput input(){ return ScalarInput(); }
VectorInput input(size_t n){ return VectorInput(n); }

template<typename T>
void print(vector<T> a){
  for(int i=0;i<a.size();i++){
    cout<<a[i]<<" \n"[i+1==a.size()];
  }
}

template<class T>
void print(T x){
    cout << x << '\n';
}
 
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail){
  cout << head << ' ';
  print(forward<Tail>(tail)...);
}


int n;
vector<int>a;
int mx;

using D=long double;
D pi=3.141592653589793238;

D calc(D mid){
  D r=mid/2;
  D sm=0;
  rep(i,n){
    D c=(2*r*r-a[i]*a[i])/(2*r*r);
    if(abs(c)>1)return 0;
    sm+=acosf128(c);
  }
  return sm;
}

D calc2(D mid){
  D r=mid/2;
  D sm=0;
  rep(i,n){
    D c=(2*r*r-a[i]*a[i])/(2*r*r);
    if(abs(c)>1)return 0;
    if(a[i]==mx)sm-=acosf128(c);
    else sm+=acosf128(c);
  }
  return sm;
}


int main(){
  //ios::sync_with_stdio(false);
  //cin.tie(nullptr);

  cin>>n;
  a.resize(n);
  rep(i,n)cin>>a[i];
  rep(i,n)mx=max(mx,a[i]);

  D ng=mx;
  D ok=1e9;

  rep(i,100){
    D mid=(ng+ok)/2;
    if(calc(mid)<=2*pi)ok=mid;
    else ng=mid;
  }
  if(calc(ok)>=2*pi-1e-6){
    //cerr<<1<<endl;
    cout<<fixed<<setprecision(20)<<ok/2<<endl;
    exit(0);
  }
  ng=mx;
  ok=1e9;

  rep(i,100){
    D mid=(ng+ok)/2;
    if(calc2(mid)>=0)ok=mid;
    else ng=mid;
  }
  //cerr<<2<<endl;
  cout<<fixed<<setprecision(20)<<ok/2<<endl;
}
accuracy: 1
time_ms: 200
memory_kb: 3896
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
template<int mod>istream &operator>>(istream &is,static_modint<mod> &a){long long b;is>>b;a=b;return is;}
istream &operator>>(istream &is,modint &a){long long b;cin>>b;a=b;return is;}
#endif
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) static_cast<void>(0)
#define debugg(...) static_cast<void>(0)
#define esper(...) static_cast<void>(0)
template<typename T1,typename T2>ostream &operator<<(ostream &os,const pair<T1,T2>&p){os<<p.first<<' '<<p.second;return os;}
#endif
using ll=long long;
using ull=unsigned long long;
using P=pair<ll,ll>;
template<typename T>using minque=priority_queue<T,vector<T>,greater<T>>;
template<typename T>bool chmax(T &a,const T &b){return (a<b?(a=b,true):false);}
template<typename T>bool chmin(T &a,const T &b){return (a>b?(a=b,true):false);}
template<typename T1,typename T2>istream &operator>>(istream &is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T>istream &operator>>(istream &is,vector<T> &a){for(auto &i:a)is>>i;return is;}
template<typename T1,typename T2>void operator++(pair<T1,T2>&a,int n){a.first++,a.second++;}
template<typename T1,typename T2>void operator--(pair<T1,T2>&a,int n){a.first--,a.second--;}
template<typename T>void operator++(vector<T>&a,int n){for(auto &i:a)i++;}
template<typename T>void operator--(vector<T>&a,int n){for(auto &i:a)i--;}
#define reps(i,a,n) for(int i=(a);i<(n);i++)
#define rep(i,n) reps(i,0,n)
#define all(x) x.begin(),x.end()
#define pcnt(x) __builtin_popcountll(x)
#define fin(x) return cout<<x<<'\n',static_cast<void>(0)
ll myceil(ll a,ll b){return (a+b-1)/b;}
template<typename T,size_t n,size_t id=0>
auto vec(const int (&d)[n],const T &init=T()){
  if constexpr (id<n)return vector(d[id],vec<T,n,id+1>(d,init));
  else return init;
}
void SOLVE();
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(16);
  #ifdef LOCAL
  clock_t start=clock();
  #endif
  int testcase=1;
  //cin>>testcase;
  for(int i=0;i<testcase;i++){
    SOLVE();
  }
  #ifdef LOCAL
  cerr<<"time:";
  cerr<<(clock()-start)/1000;
  cerr<<"ms\n";
  #endif
}
using R=long double;
void SOLVE(){
  int n;
  cin>>n;
  vector<int>x(n);
  cin>>x;
  sort(all(x));

  R l=0,r=1e9;
  rep(i,n)chmax<R>(l,R(x[i])/2);
  rep(h,120){
    R mid=(l+r)/2;
    R sum=0;
    rep(i,n){
      R costheta=(mid*mid*2-x[i]*x[i])/(mid*mid*2);
      sum+=acos(costheta);
    }
    (sum<=M_PI*2?r:l)=mid;
  }
  if(abs(l*2-x[n-1])<1e-8){
    r=1e9;
    rep(h,120){
      R mid=(l+r)/2;
      R sum=0;
      rep(i,n-1){
        R costheta=(mid*mid*2-x[i]*x[i])/(mid*mid*2);
        sum+=acos(costheta);
      }
      R costheta=(mid*mid*2-x[n-1]*x[n-1])/(mid*mid*2);
      (sum>=acos(costheta)?r:l)=mid;
    }
    fin(l);
  }
  cout<<l<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3632
final_rank: 2

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
using ll=long long;
using ld=long double;
const ld PI=acos(-1);
#define all(p) p.begin(),p.end()
int main(){
    ll N;
    cin>>N;
    vector<ld> X(N);
    rep(i,0,N) cin>>X[i];
    auto f=[&](ld r) -> ld {
        ld sum=0;
        rep(i,0,N) sum+=asin(X[i]/r);
        return sum;
    };
    sort(all(X));
    reverse(all(X));
    auto tmp=f(X[0]);
    ld ans;
    if(tmp>=PI){
        ld L=X[0],R=(1<<30);
        rep(rprp,0,1000){
            ld M=(L+R)/2;
            if(f(M)>=PI) L=M;
            else R=M;
        }
        ans=L;
    }
    else{
        ld L=X[0],R=(1<<30);
        X[0]*=-1;
        rep(rprp,0,1000){
            ld M=(L+R)/2;
            if(f(M)<0) L=M;
            else R=M;
        }
        ans=L;
    }
    cout<<fixed<<setprecision(20)<<ans/2<<"\n";
}
accuracy: 1
time_ms: 10
memory_kb: 3624
final_rank: 1

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

#define rep(i,s,n) for(int i = int(s); i < int(n); i++)
#define rrep(i,s,n) for(int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ld = long double;
using ull = unsigned long long;

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

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

using namespace std;

const ld eps = 1e-7;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >> n;
    vector<ld> a(n);
    ld ma = 0;
    int id = 0;
    rep(i,0,n){
        cin >> a[i];
        if (chmax(ma,a[i])) id = i;
    }
    ld lft = 0;
    rep(i,0,n) chmax(lft,a[i]/2);
    // decide p
    ld p = -1;
    {
        ld le = lft, ri = 1e7;
        int test = 120;
        while (test--){
            ld md = (le + ri) / 2;
            ld sum = 0;
            rep(i,0,n){
                if (i == id) continue;
                ld v = 1 - a[i]*a[i]/(2*md*md);
                sum += acosl(v);
            }
            if (sum < M_PI+eps){
                ri = md;
            }
            else {
                le = md;
            }
        }
        p = ri;
    }
    {
        ld le = lft, ri = p;
        int test = 120;
        while (test--){
            ld md = (le + ri) / 2;
            ld sum = 0;
            rep(i,0,n){
                ld v = 1 - a[i]*a[i]/(2*md*md);
                sum += acosl(v);
            }
            if (sum > M_PI*2) le = md;
            else ri = md;
        }
        if (p - ri > eps){
            cout << ri << endl;
            return 0;
        }
    }
    ld le = lft, ri = 1e7;
    int test = 120;
    while (test--){
        ld md = (le + ri) / 2;
        ld sum = 0;
        rep(i,0,n){
            if (i == id) continue;
            ld v = 1 - a[i]*a[i]/(2*md*md);
            sum += acosl(v);
        }
        ld oth = 0;
        {
            ld v = 1 - a[id]*a[id]/(2*md*md);
            oth += acosl(v);
        }
        if (sum > oth){
            ri = md;
        }
        else {
            le = md;
        }
    }
    cout << ri << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3632
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define inf 1000000007
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for(int i = (int)n-1; i >= 0; --i)
#define srep(i,a,b) for(int i = (int)a; i < (int)(b); ++i)
#define all(x) (x).begin(),(x).end()
#define SUM(v) accumulate(all(v), 0LL)
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())
#define SZ(c) (int)(c).size()
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i<(int)vec.size(); i++) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U> pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, 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;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, 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;
}
// tuple 出力
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
    if(N)os<<", ";
    os<<get<N>(t);
    out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
    os<<"(";
    out<0,tuple<Ts...>,Ts...>(os,t);
    os<<")";
    return os;
}
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define VEC(type, name, size)                                                                                                                                  \
    vector<type> name(size);                                                                                                                                   \
    IN(name)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define VV(type, name, h, w)                                                                                                                                   \
    vector<vector<type>> name(h, vector<type>(w));                                                                                                             \
    IN(name)
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)                                                                                                                         \
    vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
#define INT(...)                                                                                                                                               \
    int __VA_ARGS__;                                                                                                                                           \
    IN(__VA_ARGS__)
#define LL(...)                                                                                                                                                \
    ll __VA_ARGS__;                                                                                                                                            \
    IN(__VA_ARGS__)
#define STR(...)                                                                                                                                               \
    string __VA_ARGS__;                                                                                                                                        \
    IN(__VA_ARGS__)
#define CHR(...)                                                                                                                                               \
    char __VA_ARGS__;                                                                                                                                          \
    IN(__VA_ARGS__)
#define DBL(...)                                                                                                                                               \
    double __VA_ARGS__;                                                                                                                                        \
    IN(__VA_ARGS__)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
    for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
    scan(head);
    IN(tail...);
}
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { cout << yesno[t] << endl; }
void no(bool t = 1) { yes(!t); }
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define dbg(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define dbg(...) (void(0))
#define dump(x) (void(0))
#endif
template<typename A, typename T>
std::enable_if_t<std::is_convertible<T, A>::value> fill(A& array, const T& val)
{
    array = val;
}
template<typename A, typename T>
std::enable_if_t<!std::is_convertible<T, A>::value> fill(A& array, const T& val)
{
    for (auto& a : array) {
        fill(a, val);
    }
}
template <typename T, typename S> T ceil(T x, S y) {
    assert(y);
    return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y));
}
template <typename T, typename S> T floor(T x, S y) {
    assert(y);
    return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : x / y - (x % y == 0 ? 0 : 1)));
}
vector<int> iota(int n) {vector<int> a(n);iota(all(a), 0);return a;}
template <class T> T POW(T x, int n) {T res = 1;for(; n; n >>= 1, x *= x){if(n & 1) res *= x;}return res;}
ll pow2(int i) { return 1LL << i; }
int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }
int lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); }
// int allbit(int n) { return (1 << n) - 1; }
ll allbit(ll n) { return (1LL << n) - 1; }
int popcount(signed t) { return __builtin_popcount(t); }
int popcount(ll t) { return __builtin_popcountll(t); }
bool ispow2(int i) { return i && (i & -i) == i; }


template <class S> void fold_in(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void fold_in(vector<S> &v, Head &&a, Tail &&...tail) {
    for(auto e : a) v.emplace_back(e);
    fold_in(v, tail...);
}
template <class S> void renumber(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void renumber(vector<S> &v, Head &&a, Tail &&...tail) {
    for(auto &&e : a) e = lb(v, e);
    renumber(v, tail...);
}
template <class S, class... Args> void zip(vector<S> &head, Args &&...args) {
    vector<S> v;
    fold_in(v, head, args...);
    sort(all(v)), v.erase(unique(all(v)), v.end());
    renumber(v, head, args...);
}
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    INT(n);
    VEC(int,a,n);
    sort(all(a));
    long double mi = inf;
    long double ok = inf;
    long double ng = (ld)a.back()/2.0;
    rep(i,10000){
        long double theta = 0.0;
        long double mid = (ok+ng)/2;
        rep(j,n){
            theta += asin((ld)a[j]/(mid*2.0));
        }
        if(theta >=M_PI){
            ng = mid;
        }else{
            ok = mid;
        }
    }
    long double theta = 0.0; 
    rep(j,n){
        theta += asin((ld)a[j]/(ok*2.0));
    }
    dbg(ok);
    if(abs(theta-M_PI) <= 1e-8)chmin(mi,ok);
    ok = inf;
    ng = (ld)a.back()/2.0;
    rep(i,10000){
        long double theta = 0.0;
        long double mid = (ok+ng)/2;
        rep(j,n){
            if(j!=n-1){
                theta += asin((ld)a[j]/2.0/mid);
            }else{
                theta += M_PI - asin((ld)a[j]/2.0/mid);
            }
        }
        if(theta <= M_PI){
            ng = mid;
        }else{
            ok = mid;
        }
    }
    theta = 0.0;
    rep(j,n){
        if(j!=n-1){
            theta += asin((ld)a[j]/2.0/ok);
        }else{
            theta += M_PI - asin((ld)a[j]/2.0/ok);
        }
    }
    dbg(ok);
    if(abs(theta-M_PI)<=1e-8)chmin(mi,ok);
    cout << fixed << setprecision(60) << mi << endl;
    return 0;
}
accuracy: 1
time_ms: 340
memory_kb: 3624
final_rank: 10

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
//#define EPS 0.000000001



#define EPS 0.0000000001
#define SIZE 1005

struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{

		if(fabs(x-p.x) > EPS){

			return x < p.x;
		}else{

			return y < p.y;
		}
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}


	void debug(){

		printf("(%.3lf,%.3lf)\n",x,y);
	}

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;

struct Line{
	Line(){

	}
	Line(Point a,Point b){
		p[0] = a;
		p[1] = b;
	}
	/*void outPut(){

		printf("(%.3lf,%.3lf)-(%.3lf,%.3lf)\n",p[0].x,p[0].y,p[1].x,p[1].y);
	}*/
	Point p[2];
};

struct Circle{
	Point center;
	double r;
};

int N;
double X[SIZE];


double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}


double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

/*
 * p0を基準点として、p1から見てp2が
 * 反時計回り側にあれば
 * COUNTER_CLOCKWISE
 * */
int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

double arg(Vector p){
	return atan2(p.y,p.x);
}

Vector polar(double a,double r){
	return Point(cos(r)*a,sin(r)*a);
}

//円と円の交点
vector<Point> getCrossPoints(Circle c1,Circle c2){

	vector<Point> res;

	double d = abs(c1.center-c2.center);
	double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
	double t = arg(c2.center-c1.center);

	res.push_back(Point(c1.center+polar(c1.r,t+a)));
	res.push_back(Point(c1.center+polar(c1.r,t-a)));

	return res;
}

//点のradを求める関数
double calc_rad(Point p){

	if(p.y == 0){

		if(p.x > 0){

			return 0;

		}else{ //p.x < 0

			return M_PI;
		}

	}else if(p.x == 0){

		if(p.y > 0){

			return M_PI/2.0;
		}else{


			return 3*M_PI/2.0;
		}

	}else{

		double base = atan(fabs(p.y)/fabs(p.x));

		if(p.x > 0){

			if(p.y > 0){

				return base;

			}else{ //p.y < 0

				return 2*M_PI-base;
			}

		}else{ //p.x < 0

			if(p.y > 0){

				return M_PI-base;

			}else{

				return base+M_PI;
			}
		}
	}
}


bool is_large(double R){

	Circle C;
	C.center = Point(0,0);
	C.r = R;

	Point P = Point(R,0);
	double pre_rad = 0;

	for(int i = 0; i < N; i++){

		Circle work;
		work.center = P;
		work.r = X[i];

		double tmp_dist = calc_dist(C.center,P);
		if(tmp_dist+R+EPS < X[i]){ //workの円が、基準円を内部に含む場合

			return false;
		}

		vector<Point> vec = getCrossPoints(C,work);
		Point next_P;

		if(ccw(C.center,P,vec[0]) == COUNTER_CLOCKWISE){

			next_P = vec[0];
		}else{

			next_P = vec[1];
		}

		double next_rad = calc_rad(next_P);
		if(next_rad < pre_rad){
			if(next_rad > EPS){ //■1周した
				return false;
			}
		}
		pre_rad = next_rad;
		P = next_P;
	}

	return true;
}

bool isOK(double R){

	double maxi = 0;

	double sum = 0;
	for(int i = 0; i < N; i++){

		double tmp = 2*asin(X[i]/(2*R));
		if(tmp > maxi){
			maxi = tmp;
		}
		sum += tmp;
	}

	return sum-maxi >= maxi;
}

int main(){

	scanf("%d",&N);

	double maxi = 0;
	for(int i = 0; i < N; i++){

		scanf("%lf",&X[i]);
		maxi = max(maxi,X[i]);
	}

	double R = maxi/2;
	double base = 0;

	for(int i = 0; i < N; i++){

		base += 2*asin(X[i]/(2*R));
	}

	if(base >= 2*M_PI){

		double left = maxi/2-EPS,right = maxi*1000,mid = (left+right)/2;
		double ans = right;

		for(int loop = 0; loop < 100; loop++){
			if(is_large(mid)){

				ans = mid;
				right = mid;

			}else{

				left = mid;
			}
			mid = (left+right)/2;
		}

		printf("%.12lf\n",ans);

	}else{

		double left = maxi/2-EPS,right = maxi*1000,mid = (left+right)/2;
		double ans = right;

		for(int loop = 0; loop < 100; loop++){
			if(isOK(mid)){

				ans = mid;
				right = mid;

			}else{

				left = mid;
			}
			mid = (left+right)/2;
		}

		printf("%.12lf\n",ans);
	}

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3760
final_rank: 6

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
//#define EPS 0.000000001



#define EPS 0.0000000001
#define SIZE 1005

struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	bool operator<(const Point &p) const{

		if(fabs(x-p.x) > EPS){

			return x < p.x;
		}else{

			return y < p.y;
		}
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}


	void debug(){

		printf("(%.3lf,%.3lf)\n",x,y);
	}

	double x,y;
};

typedef Point Vector;
typedef vector<Point> Polygon;

struct Line{
	Line(){

	}
	Line(Point a,Point b){
		p[0] = a;
		p[1] = b;
	}
	/*void outPut(){

		printf("(%.3lf,%.3lf)-(%.3lf,%.3lf)\n",p[0].x,p[0].y,p[1].x,p[1].y);
	}*/
	Point p[2];
};

struct Circle{
	Point center;
	double r;
};

int N;
double X[SIZE];


double calc_dist(Point A,Point B){

	return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}


double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;

/*
 * p0を基準点として、p1から見てp2が
 * 反時計回り側にあれば
 * COUNTER_CLOCKWISE
 * */
int ccw(Point p0,Point p1,Point p2){

	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if(cross(a,b) > EPS)return COUNTER_CLOCKWISE;
	if(cross(a,b) < -EPS)return CLOCKWISE;
	if(dot(a,b) < -EPS)return ONLINE_BACK;
	if(a.norm() < b.norm())return ONLINE_FRONT;

	return ON_SEGMENT;
}

double arg(Vector p){
	return atan2(p.y,p.x);
}

Vector polar(double a,double r){
	return Point(cos(r)*a,sin(r)*a);
}

//円と円の交点
vector<Point> getCrossPoints(Circle c1,Circle c2){

	vector<Point> res;

	double d = abs(c1.center-c2.center);
	double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
	double t = arg(c2.center-c1.center);

	res.push_back(Point(c1.center+polar(c1.r,t+a)));
	res.push_back(Point(c1.center+polar(c1.r,t-a)));

	return res;
}

//点のradを求める関数
double calc_rad(Point p){

	if(p.y == 0){

		if(p.x > 0){

			return 0;

		}else{ //p.x < 0

			return M_PI;
		}

	}else if(p.x == 0){

		if(p.y > 0){

			return M_PI/2.0;
		}else{


			return 3*M_PI/2.0;
		}

	}else{

		double base = atan(fabs(p.y)/fabs(p.x));

		if(p.x > 0){

			if(p.y > 0){

				return base;

			}else{ //p.y < 0

				return 2*M_PI-base;
			}

		}else{ //p.x < 0

			if(p.y > 0){

				return M_PI-base;

			}else{

				return base+M_PI;
			}
		}
	}
}


bool is_large(double R){

	Circle C;
	C.center = Point(0,0);
	C.r = R;

	Point P = Point(R,0);
	double pre_rad = 0;

	for(int i = 0; i < N; i++){

		/*printf("\ni;%d P; ",i);
		P.debug();*/

		Circle work;
		work.center = P;
		work.r = X[i];

		double tmp_dist = calc_dist(C.center,P);
		if(tmp_dist+R+EPS < X[i]){ //workの円が、基準円を内部に含む場合

			return false;
		}

		vector<Point> vec = getCrossPoints(C,work);
		Point next_P;

		if(ccw(C.center,P,vec[0]) == COUNTER_CLOCKWISE){

			next_P = vec[0];
		}else{

			next_P = vec[1];
		}

		double next_rad = calc_rad(next_P);
		if(next_rad < pre_rad){
			if(next_rad > EPS){ //■1周した
				//printf("一周したので不可\n");
				return false;
			}
		}
		pre_rad = next_rad;
		P = next_P;
	}

	return true;
}

bool isOK(double R){

	double maxi = 0;

	double sum = 0;
	for(int i = 0; i < N; i++){

		double tmp = 2*asin(X[i]/(2*R));
		if(tmp > maxi){
			maxi = tmp;
		}
		sum += tmp;
	}

	return sum-maxi >= maxi;
}

int main(){

	scanf("%d",&N);

	double maxi = 0;
	for(int i = 0; i < N; i++){

		scanf("%lf",&X[i]);
		maxi = max(maxi,X[i]);
	}

	double R = maxi/2;
	double base = 0;

	for(int i = 0; i < N; i++){

		base += 2*asin(X[i]/(2*R));
	}

	//printf("base:%.3lf\n",base);

	if(base >= 2*M_PI){

		//printf("普通\n");

		double left = maxi/2-EPS,right = maxi*1000,mid = (left+right)/2;
		double ans = right;

		for(int loop = 0; loop < 100; loop++){
			if(is_large(mid)){

				ans = mid;
				right = mid;

			}else{

				left = mid;
			}
			mid = (left+right)/2;
		}

		printf("%.12lf\n",ans);

	}else{

		//printf("特殊\n");

		double left = maxi/2-EPS,right = maxi*1000,mid = (left+right)/2;
		double ans = right;

		for(int loop = 0; loop < 100; loop++){
			if(isOK(mid)){

				ans = mid;
				right = mid;

			}else{

				left = mid;
			}
			mid = (left+right)/2;
		}

		printf("%.12lf\n",ans);
	}

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3756
final_rank: 5